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 to check if a User database is locked?
What are the types of containers in ssis?
How to update multiple rows with one update statement in ms sql server?
What is transact-sql ddl trigger?
What are distinctive joins find as a part of sql?
What is a database in ms sql server?
What are the restrictions applicable while creating views? : SQL Server Architecture
Which table keeps the locking information?
How to add the custom code in Report?
In what three ways is the return statement used in a stored procedure?
Explain what is use of dbcc commands?
Is truncate a dml command?
Can we use having clause without group by?
Which is the latest version of sql server and when it is released?
Explain few examples of stored procedure over triggers?