Originally posted by jpk
so can composite key be something like a link between class ID to STudient ID??
i always thought it was a link from same fields. EG Class ID to Class ID
Originally posted by Huy
Composite key - created by joining 2 or more fields together.
You will only need a composite key if you have a field which cannot be guaranteed to be unique, so you combine other fields together (to form a composite key), which is definately unique.
For example "JPK.BOS.2003.IPT"
It ensures that you end up with a unique field.
E.g. anyone can have "BOS" in their field, or "2003" or even "IPT"
But if you combine all 3, as well as your DOB or any other field, it becomes unique.
That's the purpose of having a composite key, it doesn't link to any other entities like you are suggesting, (ClassID to ClassID).
ClassID might be an entity, with ClassID being another field, within that same entity.
A relationship does not exist however, between (say) "JPK.BOS.2003.IPT" and "ClassID" because the composite key was only created to be unique (an identifier).
You are getting confused between Entity-Relationship-Diagrams (ERD's or schemas) and the purpose of having keys.
To answer your question, no. A composite key cannot be "something like a link between ClassID and StudentID" - this is a relationship (be it one to one, one to many, many to many).
"A
link from the same fields" happens to be a relationship, not a composite key.