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 a periodical index?
How do I get to sql server configuration manager?
What are actions, how many types of actions are there, explain with example? : sql server analysis services, ssas
How many types of database relationship in sql server?
What is store procedure?
How to make a column nullable?
How to disable a login name in ms sql server?
What is dbcc?
Explain cross join or cartesian product in sql?
What is “begin trans”, “commit tran”, “rollback tran” and “savetran”?
What is blocking?
What guidelines should be followed to help minimize deadlocks?
What do you mean by collation recursive stored procedure?
What are the different Authentication modes in SQL Server and how can you change authentication mode?
What is meant by Active-Passive and Active-Active clustering setup?