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 > about the relation type 1:1

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-12-09, 20:47
chiefman chiefman is offline
Registered User
 
Join Date: Jan 2009
Posts: 23
about the relation type 1:1

hi guys,
I am be assailed with this relation type and trying to figure it out. I have two entities A (aid, ...) and B (bid, aid ...). for A 'aid' is the primary key, for B 'bid' is the primary key and 'aid' is the foreign key referencing A(aid). A may has 0 or 1 entity B but B must corresponds to 1 entity A, the relation between them can be described as
A (1..1) —— (0..1)B. so I think when creating table for B, bid is not necessary, aid can be the foreign key and also the primary key. please correct me if I think wrongly.
I have looked up for this case in a database book. it keeps the 'bid' in the table.
Reply With Quote
  #2 (permalink)  
Old 02-12-09, 23:26
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
you think correctly

B does not need bid, and B.aid can be both PK and FK

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-13-09, 01:58
dportas dportas is offline
Registered User
 
Join Date: Dec 2007
Location: London, UK
Posts: 732
"aid" should be a key in B (the (0..1) part of the constraint). Whether you also need "bid" depends on what that attribute means in your data model. Presumably you are implying that "bid" is just surrogate key that can be dropped without losing any information. Is that right?
Reply With Quote
  #4 (permalink)  
Old 02-13-09, 02:43
chiefman chiefman is offline
Registered User
 
Join Date: Jan 2009
Posts: 23
yes. bid is an integer and just to identify the rows in the table
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