Monday, March 3, 2014

Compound Key & Composite Key - Database

#Compound Key

A compound key consists of more than one attribute to uniquely identify an entity occurrence.

Each attribute, which makes up the key, is also a simple key in its own right.

For example, we have an entity named enrollment, which holds the courses on which a student is enrolled. In this scenario a student is allowed to enroll on more than one course. This has a compound key of both student number and course number, which is required to uniquely identify a student on a particular course.
 

Student number and course number combined is a compound primary key for the enrollment entity.

...

#Composite Key

A composite key consists of more than one attribute to uniquely identify an entity occurrence. This differs from a compound key in that one or more of the attributes, which make up the key, are not simple keys in their own right.

For example, you have a database holding your CD collection. One of the entities is called tracks, which holds details of the tracks on a CD. This has a composite key of CD name, track number.


CD name in the track entity is a simple key, linking to the CD entity, but track number is not a simple key in its own right.

...


No comments:

Post a Comment

Share Your Inspiration...