If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Quick question... very new!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-19-09, 23:30
spooks spooks is offline
Registered User
 
Join Date: Nov 2009
Posts: 3
Question Quick question... very new!

Hello, I have just started doing database design, and one thing that I am wondering is about table relationships. One to one, one to many, and many to many.

In many cases it seems simple, but if i think about it for a while, tables relationships can use either of these.

For example, you have a customer tables and an address table. I would think one customer can have one and only one address, so it would be a one to one relationship. But the opposite is not the same, as an address can belong to one or many customers (if two or more customers are living in the same house)

How do I classify this relationship? is there an easy way I can make the connection in the future, as many examples seem to be confusing me.

Thank you
Reply With Quote
  #2 (permalink)  
Old 11-20-09, 00:17
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Most of the time you can simply store address information as an attribute of person, or as a subtable if people can have more than one address, and not worry about storing the same address twice because 95% of the time we are much more interested in tracking people than tracking houses.
But if you are developing a real-estate application, or a building maintenance application, then you would want buildings to be their own entity and establish a many-to-many relationship with the tenant records.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #3 (permalink)  
Old 11-20-09, 00:55
spooks spooks is offline
Registered User
 
Join Date: Nov 2009
Posts: 3
Thanks, I will usually use address with customer information then.

But, the relationship idea is the thing that kind of bugs me. Lets say with Customers and Order. I know right now that one customer can have one order, and by that logic I will state that its a one to many relationship. one customer can have many orders.

But what stops me from saying, many customers can have many orders? That is how many to many relationships confuse me. I seem that I can use it anywhere (i know that I should use one to many, but many to many seems to also fit)

So my question is, how do I tell if something is one to many or many to many? I understand the terms, I just can't seem to make sense of it.
Reply With Quote
  #4 (permalink)  
Old 11-20-09, 05:11
Pyrophorus Pyrophorus is offline
Registered User
 
Join Date: Aug 2009
Posts: 68
Quote:
Originally Posted by spooks View Post
...one customer can have many orders.
So my question is, how do I tell if something is one to many or many to many? I understand the terms, I just can't seem to make sense of it.
Just exchange relation terms: "one order can have many customers ?". If false, this is many to one, if true, many to many.

Quote:
Originally Posted by spooks View Post
But what stops me from saying, many customers can have many orders? That is how many to many relationships confuse me. I seem that I can use it anywhere (i know that I should use one to many, but many to many seems to also fit)
Nothing stops you. It would work too, but you would have one more table in your design and more code to manage it. It would be useless complexity.

HTH
Laurent
Reply With Quote
  #5 (permalink)  
Old 11-20-09, 05:15
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
You're not alone in finding the terms confusing - so does C J Date (one of the leading relational database theorists). His article on the subject may help.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #6 (permalink)  
Old 11-20-09, 07:58
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by andrewst View Post
just had a quick look at this paper, and all i gotta say is, that guy may know his shiznitz, but he *sucks* at explaining things simply
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 11-20-09, 08:04
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
CJ Date is very precise with the language he uses and will not compromise by using "layman's" terms when there is a domain specific or expert term that is exactly what he means. Quite a lot of his writing actually is clarifying exactly what he means by statement XYZ.
IME most of this texts must be read in the context of some of his fundamental texts (though I'll admit I've not read him widely).
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #8 (permalink)  
Old 11-20-09, 08:22
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by pootle flump View Post
CJ Date is very precise with the language he uses and will not compromise by using "layman's" terms when there is a domain specific or expert term that is exactly what he means. Quite a lot of his writing actually is clarifying exactly what he means by statement XYZ.
IME most of this texts must be read in the context of some of his fundamental texts (though I'll admit I've not read him widely).
so basically you're agreeing with me, he sucks at explaining things simply
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #9 (permalink)  
Old 11-20-09, 08:31
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
He excels at explaining things precisely and unambiguously.
I don't believe his intent is to explain things simply (at least not the way you mean it) so I'm not sure if he could be said to "suck" at it.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #10 (permalink)  
Old 11-20-09, 08:39
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by pootle flump View Post
He excels at explaining things precisely and unambiguously.
I don't believe his intent is to explain things simply (at least not the way you mean it) so I'm not sure if he could be said to "suck" at it.
fair point

in that case, what sucks is recommending cjdate to someone who is struggling with simple concepts and wants simple explanations, especially if you gots to go get a university education before you can read him
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #11 (permalink)  
Old 11-20-09, 08:43
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
There's probably some truth in that. His more fundamental texts are intended for undergraduate study (the stuff you study during your degree, in case I am using UK terms here), the rest (as far as I have seen) build on those.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #12 (permalink)  
Old 11-20-09, 08:56
Pyrophorus Pyrophorus is offline
Registered User
 
Join Date: Aug 2009
Posts: 68
Quote:
Originally Posted by r937 View Post
fair point

in that case, what sucks is recommending cjdate to someone who is struggling with simple concepts and wants simple explanations, especially if you gots to go get a university education before you can read him
I think you're right, but the paper points something important IMO: the three kinds of relationships we use in databases covers much more different relations, and maybe we should better not to use them in our designs, only in implementations.
My two cents...
Laurent
Reply With Quote
  #13 (permalink)  
Old 11-20-09, 08:59
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Thought I'd dip in to the paper
Quote:
Originally Posted by C.J.
clarity, accuracy, and precision are surely paramount;
without them we're doomed.
I LOLed. It's as though he read our exchange before writing the paper.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #14 (permalink)  
Old 11-20-09, 09:44
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Quote:
Originally Posted by r937 View Post
in that case, what sucks is recommending cjdate to someone who is struggling with simple concepts and wants simple explanations, especially if you gots to go get a university education before you can read him
Oh, stop being such an inverted snob about education! Yes, some of what Date says gets quite complex and academic, but he does give some very clear examples of each possible relationship type e.g. "In a given company at a given time, each employee has exactly one department and each department has at least one employee". I would assume anyone who posts a question on this forum is actually interested in learning about databases and doesn't want "Janet has a dog. See the dog run" explanations!
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #15 (permalink)  
Old 11-20-09, 10:24
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
As a rule of thumb though Laurent's post in #4 is a good technique.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On