Click here to Skip to main content
15,909,325 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Binary one to one relationship

PK of the compulsory side becomes foreign key in the optional side.



1)my question is that what i do when both sides minimum and maximum cardinality is compulsory?



2) what is in case of Binary one to many relation ship
Posted

1 solution

Your question is unclear, hope this helps:

1:1 means that the row on the "parent" table *must* exist on the "child" table. I've used quotation marks here as they are not really parent/child as they have the same priority, really a single table has been partitioned into two. 1:1 relationships are unusual, they are normally better expressed as a single table i.e. you should avoid 1:1. I'm not even sure you could insert rows without dropping constraints (or using a trigger/transactions?) as the "row" would need to be inserted into both table simultaneously. I've never seen it done, frankly, and can't test from home.

What you describe above (PK becomes FK on child table) is 1:Many as I can insert as many rows into the child table using the parent's primary key. You can make this 1:0..1 (where either no or a single row exists in the child per parent) by placing a unique constraint on the foreign key.

Finally,if you must have 1:1 you can ditch the FK column from the "child" and make the PK on the "parent" and "child" foreign keys on the opposing table. To re-state, this is pretty unusual.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900