30 likes | 100 Views
Sometimes a Unique Key Must Be Composite. CourseSections(crsNo, facID, room, days, secNo, capacity, term, time) For example, one row might be (CSC1035, 22, MSCG86, TTh, 001, 28, F12, 4:00)
E N D
Sometimes a Unique Key Must Be Composite • CourseSections(crsNo, facID, room, days, secNo, capacity, term, time) • For example, one row might be (CSC1035, 22, MSCG86, TTh, 001, 28, F12, 4:00) • It means the course CSC1035, section 001, meets in MSC G86 on Tuesday and Thursday at 4:00 in Fall 2012. It is taught by faculty member 22 and has capacity 28.
CourseSections Example • We see that the attribute (term) isn’t a unique key. For example, many course sections may be offered in one term. • Even the composite (facID, crsNo) isn’t unique, since the same instructor may teach the same course (either in multiple sections, or over multiple terms).
CourseSections Example • However, the set (crsNo, secNo, term) is unique, so it’s a candidate key. • There are others: can you find them? • If we choose the one above as PK, we’d write: • CourseSections(crsNo, facID, room, days, secNo, capacity, term, time)