How do you implement one-to-one, one-to-many and many-to-
many relationships while designing tables?
Answer Posted / harish sharma
All relationships are implemented by primary key and
foreign keys.
One-to-one
When we use two tables to relate by one primary key in one
table and one foreign key in secound table.
for example Employee table and salary table.
One-to-many
When we use many table but primary key is only in one table
and in other tables we use foreign key to inter-relate
tables.
For example Emp_id(primary key) in Employee table is
assosiated with salary_emp_id (foreign key) in Salary table
and associated with tax_emp_id (foreign key) in
tax_collecation table and associated with pf_emp_id
(foreign key) in provident_fund table.
Many-to-many
When we use primary keys of two or more tables in a
saperate table and in this table we relate these with other
tables by foreign key and primary key
| Is This Answer Correct ? | 18 Yes | 9 No |
Post New Answer View All Answers
What is row_number function?
explain what are the steps you will take, if you are tasked with securing an sql server? : Sql server database administration
How do you create an execution plan?
What are the differences in Clustering in SQL Server 2005 and 2008 or 2008 R2?
What is a coalesce function?
Can we perform backup restore operation on tempdb?
You want to generate a report that is formatted as a chart. Can you use the report wizard to create such a report?
How to use old values to define new values in update statements in ms sql server?
Why would you use sql agent?
how you can get the list of largest tables in a database? : Sql server administration
Why we use functions in sql server?
How do I save a stored procedure in sql server?
Define inner join? Explain with an example?
How to search for a string in all stored procedure in sql server?
What are xml indexes?