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


Please Help Members By Posting Answers For Below Questions

What to check if a User database is locked?

588


What are the types of containers in ssis?

603


How to update multiple rows with one update statement in ms sql server?

638


What is transact-sql ddl trigger?

634


What are distinctive joins find as a part of sql?

558






What is a database in ms sql server?

550


What are the restrictions applicable while creating views? : SQL Server Architecture

586


Which table keeps the locking information?

528


How to add the custom code in Report?

99


In what three ways is the return statement used in a stored procedure?

514


Explain what is use of dbcc commands?

511


Is truncate a dml command?

503


Can we use having clause without group by?

556


Which is the latest version of sql server and when it is released?

548


Explain few examples of stored procedure over triggers?

523