Hi
How do you implement One to One, One to Many and Many to Many relationships while designing the tables ?
One to One, One to Many and Many to Many Relationship
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
SenthilkumarRank #387 · 6.5K reputationPosted Apr 13, 2012, 10:33 PM EDT
The relations are enforced in sql server using the keys.
Consider, there are two tables. Table1 and Table2. Both table have the primary key and each table referenced by the foreign key. It will maintain one to one relationship between these two tables.
One-to-many relationship maintained by enforcing the key relationship in the table2 and it will have the many entries for the parent table.
Consider, Product is table where it will have the primary key. These table is base table or master table.
Sales table where it will have the multiple entries for the master record. This is called one-to-many.
Like that you can see many examples,,
http://sqlserver-tips.blogspot.in/2006/10/implementing-one-to-one-relationship.html
http://www.mssqltips.com/sqlservertip/2380/sql-server-database-design-with-a-one-to-one-relationship/
http://sqlblogcasts.com/blogs/tonyrogerson/archive/2010/01/23/how-to-create-a-one-to-one-relationship-in-sql-server-using-dri-triggers-and-views.aspx
http://stackoverflow.com/questions/1308339/create-a-one-to-many-relationship-using-sql-server