Welcome Message

Hi, welcome to my website. This is a place where you can get all the questions, puzzles, algorithms asked in interviews and their solutions. Feel free to contact me if you have any queries / suggestions and please leave your valuable comments.. Thanks for visiting -Pragya.

July 11, 2010

Implementing one-to-many relationship

One-to-many relation can be implemented by using two tables.. in two ways :

e.g we have a Department table and a Student Table

1. Department :
DeptID -> Primary Key
DeptName
DeptHead

Student :
StudentID -> Primary Key
StudentName
DeptID -> Foreign Key

2. Department :
DeptID -> Primary Key
DeptName
DeptHead

Student :
StudentID -> Composite Primary Key - 1
StudentName
DeptID -> Composite Primary Key - 2

No comments: