Database Design & Development · Design

DDD2 — ER diagrams: entities, attributes, relationships

📅 Thu 8 Oct 2026
~100–110 minutes · double period
Learning intentions
Success criteria
Warm up — what do you already know?

Answer before the lesson begins — it's fine if you're unsure.

WU1
1. In DDD1 you wrote requirements for a sports club database. Which of these is a functional requirement, not an end-user requirement?
WU2
2. National 5 recap: the field (or combination of fields) that uniquely identifies each record in an entity is called the ___ key.
WU3
3. Which of these is not one of the four entities identified for the Craigmillar Community Sports Club database in DDD1?

Key vocabulary

Entity
A person, place, thing, event, or concept that the database needs to store data about — drawn as a rectangle.
Attribute
A piece of information stored about an entity — for example a Member's surname or a Class's start time.
Relationship
A named connection between two entities, describing how records in one relate to records in the other — for example "teaches" or "makes".
Primary key
The attribute that uniquely identifies each record in an entity. Shown underlined in an ER diagram.
Foreign key
An attribute in one entity that links to the primary key of another entity. Shown with an asterisk (*) in an ER diagram.
Crow's-foot notation
The set of symbols used on the relationship line to show cardinality — a fork ("crow's foot") marks the "many" side.

Entities, attributes, and relationships

What is an entity?

An entity is a person, place, thing, event, or concept that a database needs to hold data about. In the Craigmillar Community Sports Club scenario from DDD1, the entities are Member, Class, Instructor, and Booking — one entity for each distinct "thing" the club's stakeholders talked about. On an ER diagram, an entity is drawn as a labelled rectangle. The Higher course requires every ER diagram to have three or more entities, which the sports club scenario comfortably satisfies with four.

What is an attribute?

An attribute is a single piece of information stored about an entity — the same idea as a field from National 5, just applied at the design stage before any table exists. Each entity needs enough attributes to satisfy the functional requirements identified in DDD1. For example, the requirement "the database must have a query to calculate the average fee per session" tells us Class needs a feePerSession attribute; the requirement "sort members by the date they joined" tells us Member needs a dateJoined attribute. Attributes are traced directly back to requirements, not invented arbitrarily.

Primary keys and foreign keys, briefly revisited

Every entity needs a primary key — a single attribute that uniquely identifies each record. Each attribute is drawn in its own oval connected to the entity rectangle by a plain line. Member's primary key is memberID; Class's is classCode. The primary-key text is underlined inside its oval. When one entity needs to refer to a record in another entity, it stores that entity's primary key as a foreign key, marked with an asterisk in the attribute oval. Booking therefore has memberID * and classCode * as foreign keys. DDD4 covers data dictionaries and compound keys in full detail — this lesson only needs enough of the key concept to draw sensible attribute ovals and relationship lines.

Naming a relationship

A relationship is the named line joining two entities on an ER diagram. The name should be a short verb phrase describing what one entity does to, or with, the other — "teaches", "makes", "generates" — not a noun. A relationship name should make sense read in one direction: "Instructor teaches Class" reads naturally; "Instructor Class" does not. Three relationships link the sports club's four entities: Instructor teaches Class, Class generates Booking, and Member makes Booking.

Reading crow's-foot notation

The line joining two entities carries a symbol at each end to show cardinality — how many records on one side can relate to how many on the other. SQA's house style uses crow's-foot notation: a fork (three short diverging lines) at the "many" end of a relationship, and a plain line at the "one" end. In the diagram below, the fork sits at Class's end of the "teaches" line, because one instructor teaches many classes, but each class has only one instructor. This lesson focuses on reading and drawing that notation correctly once you're told which side is "many" — working out which side is many, and why, for a relationship you haven't seen before is the focus of DDD3.

Worked examples

Example 1 — From requirement to entity and attribute
1
Requirement: "The database must have a query to select classes with available spaces, comparing bookings against capacity" (from DDD1's Example 3).
2
This requirement mentions two entities working together: Class (which has a capacity) and Booking (the records being counted against it).
3
It confirms Class needs a capacity attribute, and confirms that Booking must link back to Class — which is exactly what the classCode foreign key does.
Every attribute oval in the complete diagram below can be traced back to a DDD1 requirement in this way — that's what makes it "correct" rather than guessed.
Example 2 — Drawing the Instructor entity and its attributes
1
Draw a rectangle and label it with the entity name: Instructor.
2
Draw a separate oval for each attribute — instructorRef, firstName, surname, and qualified — and connect every oval to the Instructor rectangle with one plain line.
3
Underline instructorRef inside its oval because it uniquely identifies each instructor. None of Instructor's attributes are foreign keys, so none of its ovals needs an asterisk.
Compare your drawing with the Instructor cluster in the complete diagram below: one rectangle, four connected attribute ovals, and only instructorRef underlined.
Example 3 — Naming and drawing the Instructor–Class relationship
1
Identify the two entities involved: Instructor and Class.
2
Choose a verb phrase describing what an instructor does to a class: teaches. "Instructor teaches Class" reads naturally.
3
Draw a line between the two entity rectangles, labelled "teaches", with a crow's foot at the Class end — because one instructor teaches many classes, but each class has only one instructor.
See the full diagram below for how all three relationships (teaches, generates, makes) fit together across all four entities.

The sports club's complete ER diagram

The single diagram below brings the whole design together. Each entity is a named rectangle; every attribute has its own connected oval. Primary-key text is underlined, foreign-key text has an asterisk, and the three entity-to-entity relationship lines use crow's-foot notation. Scroll horizontally to inspect the complete diagram if it is wider than your screen.

Complete Craigmillar Community Sports Club entity-relationship diagram Four entity rectangles with 23 separate attribute ovals. Primary keys are underlined, foreign keys have an asterisk, and three labelled one-to-many relationships use crow's feet at Class and Booking. teaches generates makes Instructor Class Booking Member instructorRef firstName surname qualified classCode className instructorRef * dayOfWeek startTime capacity feePerSession bookingRef memberID * classCode * bookingDate attended memberID firstName surname address town postcode dateJoined
↔ Scroll horizontally if needed. The complete Craigmillar Community Sports Club ER diagram uses a separate connected oval for every attribute: primary-key text is underlined and foreign-key text has an asterisk. The crow's foot (fork) sits at the "many" end of each entity-to-entity relationship — here, at Class and at Booking on both of its relationships.
🛠️ Tool for this lesson — draw.io

From here on, build your ER diagrams in draw.io rather than describing them in words. Use a plain rectangle for each entity, build every attribute oval as a separate shape, join each oval to its entity with a plain line, underline primary-key text, and add an asterisk to foreign-key text. Use labelled crow's-foot connectors only between entity rectangles. See the draw.io ER Diagram Guide for the exact steps, including which connector ends to use and which to avoid.

Now you try

Open draw.io and build the Booking entity as a plain labelled rectangle. Add a separate connected oval for each of its five attributes, underline the primary key, and mark both foreign keys with an asterisk. The ovals can be arranged clearly around the rectangle in any sensible positions.

Booking bookingRef memberID * classCode * bookingDate attended

Compare your draw.io diagram against this: bookingRef is underlined in its oval (primary key), memberID * and classCode * are the foreign-key ovals, and bookingDate and attended are plain attribute ovals.

⚠️ Common mistakes — examiner feedback
📝 Exam tip

When a question says "exemplify" an ER diagram, it wants an actual labelled diagram — entity rectangles, separate connected attribute ovals, primary-key text underlined, foreign-key text marked with *, and named relationship lines with crow's-foot notation — not a written description of what the diagram would contain. A correct written description without the diagram itself will not gain full marks.

Task Set B — Core questions
Work through all questions. B6–B8 and B10 are built in draw.io — self-assess against the model diagram shown on reveal.
B1
On an ER diagram, an entity is drawn as a labelled ___.
B2
Which symbol marks a foreign key in an ER diagram attribute oval?
B3
What is the primary key of the Class entity in the Craigmillar Community Sports Club database?
B4
Name both foreign keys stored in the Booking entity, in any order. Separate the two names with a comma or a space.
B5
Which of these is the most appropriate name for the relationship between Class and Booking?
B6
Build the Instructor entity in draw.io: a plain labelled rectangle with a separate connected oval for each attribute. Underline its primary key; no foreign-key asterisks are needed. Arrange the ovals clearly around the rectangle.
Model diagram
Instructor instructorRef firstName surname qualified
B7
In draw.io, connect Class and Booking with the correct crow's-foot connector ends, and label the relationship. Then explain your choice below.
Model diagram
generates Class Booking
Plain line at Class ("one"), crow's foot at Booking ("many").
B8
Build the Member entity in draw.io: a plain labelled rectangle with a separate connected oval for each attribute. Underline its primary key; no foreign-key asterisks are needed. Arrange the ovals clearly around the rectangle.
Model diagram
Member memberID firstName surname address town postcode dateJoined
B9
Why does Booking need both a memberID foreign key and a classCode foreign key?
B10
Build the complete Craigmillar Community Sports Club ER diagram in draw.io: all four entity rectangles, every attribute in a separate connected oval, correctly marked primary/foreign keys, and all three named relationships with crow's-foot ends on the correct side.
Model diagram

This is the same complete ER diagram shown in the notes — scroll up to compare its entity rectangles, connected attribute ovals, key markings, and relationship lines with your draw.io build.

Task Set C — Extension · Beyond the specification
Optional challenge questions. Not required for your exam.
C1
Suppose the club wanted to add a fifth entity, Payment, to record how members pay for their bookings. What attributes might it need, and which existing entity would it most naturally link to?
One possible answer
C2
The foreign key linking Instructor and Class is stored in Class (instructorRef), not in Instructor. Explain why storing it the other way round wouldn't work for this scenario.
One possible answer
C3
Booking links Member and Class together. Is Booking still a "real" entity in its own right, or does it only exist to connect the other two? Justify your answer using its attributes.
One possible answer

📁 File this in OneNote under:
Higher Computing Science → Database Design & Development → DDD2

📌 Teacher notes — Shift+T to hide

Suggested timing: 8 min warm up · 15 min notes & entity/attribute notation · 12 min worked examples & ER diagram walkthrough · 10 min draw.io onboarding (first use in DDD — walk through DrawioGuide.html's setup, entity rectangles, attribute ovals, and connector shapes together before pupils touch it independently) · 10 min now you try · 22 min Task Set B (B10 added, 19 Jul 2026 unit audit — the culminating full-diagram build; the two extra minutes and the draw.io onboarding both draw on this lesson's documented slack) · 5–10 min Task Set C / review, if time allows. Creating separate ovals and connectors takes longer than typing attributes into one shape, so use the documented double-period slack and model the workflow efficiently. This lesson has documented slack (double period, single-period content per DDD.md §11/§6), which is exactly what absorbs B10 without displacing anything else.

Key misconception: pupils very commonly draw Member as an attribute oval connected to Booking rather than recognising Booking stores only the member's key, memberID *. Worth addressing directly using the C3 extension question or a live example.

Live demo suggestion: project the entity-relationship SVG diagram and physically trace each line while asking "which end is many, and why?" before pupils attempt B7 — this rehearses reading crow's-foot notation live, ahead of DDD3's deeper cardinality-reasoning content.

SQA command words covered: "exemplify" (produce an actual labelled diagram, not a written description — see the exam tip box), "describe".

Extension suggestion: pupils who finish Task Set C early could sketch a rough ER diagram (in words) for a completely different scenario of their choosing, using the same four-part checklist (entities, attributes, primary/foreign keys, named relationships) taught in this lesson.

Deliberate scope limit: this lesson does not ask pupils to derive cardinality from a scenario — all three relationships are given as established facts from DDD1's requirements. Reasoning about why a relationship is one-to-one, one-to-many, or many-to-many (and entity-occurrence diagrams as the tool for showing that reasoning) is DDD3's job, not this lesson's.