Loading...
A database model describes the entities and relationships required by a problem. Choose identifiers and cardinalities from stated rules rather than from the sample rows alone.
What you'll be able to do
An entity represents a relevant kind of thing, such as Student or Course. Attributes describe instances, such as a student’s name. An entity description lists these attributes and identifies the key; a relational implementation stores corresponding rows and columns under an agreed schema.
A name is not automatically a suitable unique identifier. Two students can share a name and a person’s name can change. Choose a stable key from the requirements or introduce an identifier. A candidate key is a minimal unique identifier; one is selected as the primary key.
Cardinality describes how many instances may participate, such as one course having many enrolments. A many-to-many relationship between students and courses can be represented by Enrolment, with one row for each allowed student/course combination.
A composite primary key can combine StudentID and CourseID when the combination uniquely identifies an enrolment under the stated rules. A foreign key references a suitable key in another relation, helping enforce valid relationships. A foreign key need not itself be unique: many enrolments can reference one student.
An entity relationship diagram makes relationship multiplicity visible. Optionality distinguishes whether a relationship is required or may be absent. A small sample containing only one enrolment per student does not prove that the real rule is one-to-one.
Translate the model into relations and check insertion/deletion cases. Does a new student require an enrolment immediately? Can deleting a course leave invalid enrolment references? Constraint and deletion policies should reflect the requirements rather than be guessed from the most convenient screen design.
| Relation | Attributes | Key role |
|---|---|---|
| Student | StudentID, Name | StudentID primary key |
| Course | CourseID, Title | CourseID primary key |
| Enrolment | StudentID, CourseID, Score | Composite primary key; both IDs also foreign keys |
Attempt the task before opening its worked response. Record each change of state, explain the rule used, and check the result against the original requirements. Code examples labelled Python 3 use that language’s conventions; pseudocode states its own assumptions.
Common mistakes to avoid
Key takeaways
Test yourself
Answer a few questions, then review anything you missed.
Start with the quiz above to check the key ideas. You can also choose another topic from the practice library.