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 the system function to get current user's user id? : Sql server database administration
How to convert binary strings into integers in ms sql server?
How many null values we can have in a unique key field in sql server?
What is public role in sql server?
What is the difference between varchar and nvarchar datatypes?
Name the different type of indexes in sql?
Is candidate a key?
How to connect ms access to sql servers through odbc?
What are partitioned views?
Which rendering formats are affected by the pagesize properties?
tell me what are the steps you will take to improve performance of a poor performing query? : Sql server database administration
what is a major difference between sql server 6.5 and 7.0 platform wise? : Sql server database administration
How to encrypt Strored Procedure in SQL SERVER?
How to disable triggers using "disable trigger"?
What options are available to audit login activity? : sql server security