By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,650 Members | 1,785 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,650 IT Pros & Developers. It's quick & easy.

composite primary key

P: 1
Hi Guys,

I am new to Database and Postgresql.

I created an ERD diagram to store information on students, parents, teachers and schools, part of my design instead of having address for each entity I create a new entity called address and contains a composite primary key from (studentID, partentID, techerID, schoolID), streetName, suburb, postcode and state:

• Student can have one or more Address
• Parent can have one or more Address
• Teacher can have one or more Address
• School can have one or more Address

I used this method avoid the redundancy for address, and I created the tables for each (student, parent, teacher, school, address) then I populated the tables with values using “INSERT VALUE” statement, but I have problem now when I am inserting values for address because I have enter the (studentID, partentID, techerID, schoolID) for each row and the issue is say for instance a studentID and prentID may have the address but for the teacher and school may have different address.

I designed the database to have a separate entity for address and with composite primary key from (studentID, partentID, techerID, schoolID), but after populating the values for the address table how do I know which address belongs to whom, because I have to have 4 IDs from the (studentID, partentID, techerID, schoolID), I am really confuse.

Thank you in advance.
Nov 3 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.