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 > Identifying versus non-identifying relationships

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #31 (permalink)  
Old 09-13-08, 13:17
ronnyy ronnyy is offline
Registered User
 
Join Date: Feb 2008
Posts: 43
Quote:
Originally Posted by r937
yes, there is, but in this case you wouldn't want to, because it would be redundant with the primary key
I started reading this thread to better understand the idenfiying/non-identifying relationships.
It seemed to me that the identifying/non-identifying relationships boils down to, do we add a surogate key or not?


Now r937, why do you say it is redundant? Maybe I didn't understand it right.
Asuming that column1 and column2 form togheter the natural key, I thought that by adding a surrogate key, and by adding a constraint UNIQUE (column1, column2) , there shouldn't be any problem, and it's better than the table without the constraint just with the surrogate key.
This way you avoid having doubles in your table, and you have a surogate key. There is a small penalty for inserts and deletes, but it's not that huge.


Thanks
Reply With Quote
  #32 (permalink)  
Old 09-13-08, 14:46
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by ronnyy
Now r937, why do you say it is redundant? Maybe I didn't understand it right.
the example that i said was redundant is this --

suppose a table with PK of (foo,bar)

then declaring a unique key of (foo,bar) would be redundant
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #33 (permalink)  
Old 09-14-08, 04:05
ronnyy ronnyy is offline
Registered User
 
Join Date: Feb 2008
Posts: 43
Quote:
Originally Posted by r937
the example that i said was redundant is this --

suppose a table with PK of (foo,bar)

then declaring a unique key of (foo,bar) would be redundant
I agree.

what about this case

Id (surrogate key) (PK),
foo,
bar
+ CONSTRAINT UNIQUE(foo,bar)
Reply With Quote
  #34 (permalink)  
Old 09-14-08, 05:53
Frunkie Frunkie is offline
Gives Bad Advice
 
Join Date: Mar 2007
Location: 010101010110100
Posts: 791
Quote:
Originally Posted by ronnyy
I agree.

what about this case

Id (surrogate key) (PK),
foo,
bar
+ CONSTRAINT UNIQUE(foo,bar)
The Id column would be unique by itself and foo and bar together would be unique.
Reply With Quote
  #35 (permalink)  
Old 09-14-08, 06:49
dportas dportas is offline
Registered User
 
Join Date: Dec 2007
Location: London, UK
Posts: 732
In ER modelling terms a relationship is called an identifying one if it corresponds to a foreign key that is some part of a primary key. However, the distinction between identifying and non-identifying is of questionable value as soon as you have more than one candidate key.

In your example, assuming both keys are enforced by uniqueness constraints, it really doesn't matter which candidate key ("id" or "foo,bar") you call the "primary" one. The semantics and the end results are exactly the same in either case. Yet ER modelling insists on describing the relationship differently depending on which key you choose to call "primary".

Decide what keys you need in your database to model the problem accurately. Don't worry too much about the identifying vs non-identifying concept.
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