How do you implement one-to-one, one-to-many and many-to-
many relationships while designing tables?
Answers were Sorted based on User's Feedback
Answer / swapna
One-to-One relationship can be implemented as a single
table and rarely as two tables with primary and foreign key
relationships.
One-to-Many relationships are implemented by splitting the
data into two tables with primary key and foreign key
relationships.
Many-to-Many relationships are implemented using a junction
table with the keys from both the tables forming the
composite primary key of the junction table.
It will be a good idea to read up a database designing
fundamentals text book.
| Is This Answer Correct ? | 48 Yes | 2 No |
Answer / 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 |
Answer / sundar
One-to-One relationship can be implemented as a single
table and rarely as two tables with primary and foreign key
relationships.
One-to-Many relationships are implemented by splitting the
data into two tables with primary key and foreign key
relationships.
Many-to-Many relationships are implemented using a junction
table with the keys from both the tables forming the
composite primary key of the junction table.
| Is This Answer Correct ? | 7 Yes | 2 No |
Explain indexing and what are the advantages of it?
What will happen if a column containing char type data is changed to the nchar data type?
What gets stored inside msdb database?
explain extended properties
What are the advantages of log shipping?
How to insert stored procedure result into temporary table?
How many types of attribute relationships are there? : sql server analysis services, ssas
Do you know what is raid and what are different types of raid configurations? : SQL Server Architecture
How to run sql server 2005 books online on your local system?
What is a rollup clause?
Can we use where and having clause together?
Explain timestamp datatype?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)