Hi
How do you implement One to One, One to Many and Many to Many relationships while designing the tables ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Apr 14, 2012, 2:33 AM
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