1:1 Relationships
-
Hi, I'm a little confused with my table relationships. I have a Customer table and Title table. Title is something like Mr., or Miss., etc. I have a foreign key reference in the Customer table to the Title. How would I read this relation. ...for each customer there is only 1 title, and for each title there is only one customer, or ...for each customer there is only 1 title, and for each title there is one or many customers?? This is a 1:1 relation, or 1:M? Please help. Regards
-
Hi, I'm a little confused with my table relationships. I have a Customer table and Title table. Title is something like Mr., or Miss., etc. I have a foreign key reference in the Customer table to the Title. How would I read this relation. ...for each customer there is only 1 title, and for each title there is only one customer, or ...for each customer there is only 1 title, and for each title there is one or many customers?? This is a 1:1 relation, or 1:M? Please help. Regards
This is how you read: For each customer you can only have one title, and for each title you can have one or more customers.
-
Hi, I'm a little confused with my table relationships. I have a Customer table and Title table. Title is something like Mr., or Miss., etc. I have a foreign key reference in the Customer table to the Title. How would I read this relation. ...for each customer there is only 1 title, and for each title there is only one customer, or ...for each customer there is only 1 title, and for each title there is one or many customers?? This is a 1:1 relation, or 1:M? Please help. Regards
As John says, a foreign key provides a one-to-many relationship. A one-to-one relationship doesn't make much sense as you may as well combine the tables into one. I'm not sure you can even create such a relationship because you'd have to simultaneously insert into both tables in order not to break the constraint. Anyone?
Regards, Rob Philpott.
-
As John says, a foreign key provides a one-to-many relationship. A one-to-one relationship doesn't make much sense as you may as well combine the tables into one. I'm not sure you can even create such a relationship because you'd have to simultaneously insert into both tables in order not to break the constraint. Anyone?
Regards, Rob Philpott.
Rob Philpott wrote:
A one-to-one relationship doesn't make much sense as you may as well combine the tables into one. I'm not sure you can even create such a relationship because you'd have to simultaneously insert into both tables in order not to break the constraint. Anyone?
1-to-1 relationships can make sense in some circumstances when dealing with optimisation of very large rows, especially if some of the columns are only very rarely neaded. It is also useful when dealing with joining separately maintained systems that need to keep in sync (e.g. if you buy in a third party system and want to extend it without touching its database tables) Typically it would actually be a zero-to-one because you insert one row then they other. Parent ------ ID PK Col1 Col2 Col3 Child ----- ID PK FK Col4 Col5 Col6 The Child row is optional, but there can be only one as its primary key is also the foreign key (which forces the oneness of the relationship)
Upcoming FREE developer events: * Glasgow: SQL Server Managed Objects AND Reporting Services ... My website
-
Hi, I'm a little confused with my table relationships. I have a Customer table and Title table. Title is something like Mr., or Miss., etc. I have a foreign key reference in the Customer table to the Title. How would I read this relation. ...for each customer there is only 1 title, and for each title there is only one customer, or ...for each customer there is only 1 title, and for each title there is one or many customers?? This is a 1:1 relation, or 1:M? Please help. Regards
-
This is a 1:M relationship. The reason being that you can have many Mr. or Mrs. Customers but a customer can only be ONE either Mr. or Mrs. Anyone???
Skan If you knew it would not compile why didn't you tell me?!?!?!
Skanless wrote:
Anyone???
Do you mean other than the two people who answered the question before you?
Upcoming FREE developer events: * Glasgow: SQL Server Managed Objects AND Reporting Services ... My website