A college stores its records in three tables:
StudentID is the primary key of STUDENT, and CourseCode is the primary key of COURSE. Each ENROLMENT row must refer to an existing student and an existing course and must specify a term.
A student can take many courses, each course has many students, and a student who fails a course may retake it in a later term. A student takes a given course at most once in a given term.
Which statement correctly identifies the foreign keys and a suitable composite primary key for ENROLMENT?
The primary key is (StudentID, CourseCode), and neither column is a foreign key because both are part of the primary key.
StudentID is the primary key of ENROLMENT, and CourseCode is a foreign key that refers to COURSE.
StudentID and CourseCode are each foreign keys, and (StudentID, CourseCode, Term) is a suitable composite primary key.
ENROLMENT needs no primary key, because it only links STUDENT to COURSE and its rows are reached through those tables.
Unlock full course notes by signing up
Applying two membership filters
A recreation centre tests two alternative filters on its membership table. Apply each rule independently to every member, and enter keep or omit in each answer cell.
Rule P keeps a row when Age is at least 18 AND Fee paid is Yes.
Rule Q keeps a row when Age is at least 18 OR Fee paid is Yes. Here, OR includes rows that satisfy both conditions.
Predicting the result of an inner join
A distributor stores its sales representatives and their sales in two tables.
SALESREP
SALE
Planning a three-table query for a marketing list
A fitness chain records its data in three tables:
MEMBER(MemberID, Name, HomeClubID, JoinDate)
CLUB(ClubID, City)
Following successive inventory changes
A stationery shop performs two operations on the inventory table below. Each operation completes before the next begins, and no other changes occur.
UPDATE: Increase Units by 3 for every row whose Category is Pen AND whose Status is Active.
DELETE: Remove every row whose Status is Clearance OR whose Units value is 0.