Construct an entity relationship diagram (ERD) by identifying the required entities, assigning their attributes and keys, and then connecting the entities with correctly labelled relationships, cardinalities, and optionalities. Resolve any many-to-many relationships before finalizing the database design.
Construction Process
- Read the scenario and identify significant objects about which data must be stored. These become entities, such as
STUDENT,COURSE, orTEACHER. - List each entity's attributes, such as
StudentID,Name, andDateOfBirth. Attributes should describe one entity and normally contain atomic values. - Select a primary key that uniquely identifies every record. Mark it using the notation required in the question, such as underlining it or writing
PK. - Identify relationships by finding verbs in the scenario. For example, a student enrols in a course.
- Add cardinality and optionality at both ends of every relationship.
- Resolve each many-to-many relationship using an associative entity. Transfer the relevant primary keys into it as foreign keys.
| Relationship | Meaning | Example |
|---|---|---|
| One-to-one | Each instance relates to at most one instance of the other entity | One person has one passport |
| One-to-many | One instance can relate to several instances of another entity | One teacher teaches many classes |
| Many-to-many | Many instances can relate to many others; this must be resolved | Many students take many courses |
For example, the many-to-many relationship between STUDENT and COURSE becomes two one-to-many relationships through ENROLMENT. ENROLMENT could contain StudentID and CourseID as foreign keys, often forming a composite primary key.
A common misconception is that every noun must become an entity. A noun should instead be an attribute when it only describes another entity and does not require its own stored records.
Exam Technique
In an IB Computer Science A3.2 response, ensure every entity has a primary key, relationship lines are unambiguous, and cardinality is shown at both ends. Check that foreign keys support the relationships and that no unresolved many-to-many relationship remains.