Students take many courses, and courses have many students. How is this modelled?
- It is a many-to-many relationship.
- Create a link table, Enrolment.
- It holds StudentID and CourseID as foreign keys.
Answer With a link table holding both foreign keys
A-level Computer Science revision · Exchanging data
A relational database stores data in tables (relations) linked by keys. A primary key uniquely identifies each record. A foreign key is a field (or fields) that refers to the primary key of another table, creating a relationship. Relationships are one-to-one, one-to-many or many-to-many; many-to-many needs a link table. Secondary keys are indexed for fast searching.
Watch out A many-to-many relationship cannot be implemented directly; it needs a linking table.
Students take many courses, and courses have many students. How is this modelled?
Answer With a link table holding both foreign keys
What is a foreign key?
A customer can place many orders, but each order belongs to one customer. This is:
Why are secondary keys indexed?
Answer An index lets the database find records by that field quickly without searching every record, speeding up common queries.
A-level Computer Science Pro, OCR H446
£119 once
Price rises to £199 on 1 January. Save £80 by joining before then.
At least 12 months of access
No VAT is charged.