Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
NewToSQLserver
Starting Member
6 Posts |
Posted - 2010-12-17 : 07:03:31
|
Hello,I have a few questions regarding OneToOne Relationship concept. I have given number to my five questions to organize my questions.So If we have two tables, Lets say one called Husbands and one called wives. Lets forget about men or woman having more than one wife or husband. Each husband have one wife and Each wife has one husband. 1) So that makes it one to one? So each row matches with one row on the other table? 2) But what if some wifes, their husband dies? So those women have zero husband. Is that still a one to one relationship between the tables?My other questions are:3) Does each row has to match one row in the other table in order for that to be called one to one relationship?4) What if some rows in one table don't match any rows in the other table and wise versa, some rows in other table don't match with any rows in the first table? Is that still one to one relation?5) My other question is in the tutorial, it says, first table second table and so on. Who decides which table is the first one, and which is the second? Does it matter which table we call first and which table we call second?Thanks for your helps |
|
Kristen
Test
22859 Posts |
Posted - 2010-12-17 : 07:45:34
|
Either you have 1:1 where a row MUST exist on both sides (and this is enforced), or you have 1:1 where a row in the other table is optional (you may then have a "First / Primary" table where there is always a row, and a row in the "Secondary" table is optional, or you might have a situation where a row in EITHER table is optional.The essence being, though, that you can NOT have more than one row in the "other table".In order to enforce the rule of 1:1 you have to create both records at the same time - this may not be feasible in practice, so you may always create whichever you perceive to be the Primary table first and then ensure that a row is created in the Secondary table shortly thereafter (maybe the user has to fill in an additional screen, or maybe you have an Exception Report that lists records that only have Primary record and no Secondary record.)In general 1:1 relationships COULD be stored in a single table, but you have decided to split the data into two tables for some reason. |
|
|
|
|
|
|
|