From text to diagram: design choices

After this lesson you will turn a requirements text into an ER diagram the way the exercise sessions do — five passes, written assumptions — and defend every choice: entity or attribute, which element an attribute belongs to, when a relationship must become an entity, when a subclass earns its place.

Late in its role-playing-game exercise, the ER exercise session prints a table (p. 1318). A character called Axel has dealt killing blows to goblins with three different multipliers, and the slide just before it (p. 1317) draws the diagram meant to hold the rows: a relationship Killing Blow between Character and Monster, carrying KB Amount and KB Multiplier.

Character NameMonster NameKB AmountKB Multiplier
AxelGoblin151.2
AxelGoblin101.5
AxelGoblin81.0
circled: "Standard Kill"

Three rows, one pair of participants: Axel and the Goblin. That diagram can keep only one of the three. The rule that forbids the other two is printed in the lecture, in a sentence about an employee who works in the same department twice. Spot it on the way; in the last section you move the multiplier yourself and watch the missing rows come back.

Entity or attribute: two tests

Page 73 lists the "Crucial design choices" of conceptual design as three questions: "Should a concept be modeled as an entity or an attribute? Should a concept be modeled as an entity or a relationship? Identifying relationships: Binary or ternary? Aggregation?" The first two decide most of a diagram, and the lecture answers each with one example.

Take an employee and her address (p. 74). If every employee has one address and you only ever print it on an envelope, an attribute of Employee is enough. The slide names the two situations in which it is not:

Two tests: several values for one owner, or a structure you need to look inside — either one makes the concept an entity, linked to its owner by a relationship.

The car-rental exercise of the session applies both tests without naming them. The inspecting company is one name with nothing inside: the attribute Company Name (p. 1296). The licence's "list of vehicles they are allowed to drive" is several values, but a short fixed list of yes-or-no facts: the composite attribute Drives, one component per category — Truck, Cars, Bus, … (p. 1295).

"Structure forces an entity, so the museum's location (address and city) must be an entity." Not in the session's notation. The lecture's dialect (pp. 68–76) knows only atomic, single-valued attributes; the session adds the composite attribute, made of named parts, and draws exactly that location as one (p. 1306). Asked "attribute or entity?" at the exam, give the slide's two tests and say which one decides.

The same tests, on a relationship

The tests bite harder on the attributes of a relationship (p. 75). Say Joe worked in the toy department from 2015 to 2016 and came back in 2019. Work_In4 links Employee and Department and carries from and to. The slide's verdict: "Works_In4 does not allow an employee to work in a department for two or more periods (a relationship is identified by participating entities)."

A relationship instance is the pair (Joe, Toys) and nothing more; from and to only describe it. A second period would need a second instance with the same pair — which is the same instance. The fix repeats the address case: "We want to record several values of the descriptive attributes for each instance of this relationship. Accomplished by introducing new entity set, Duration." Duration is identified by from and to together, Work_In4 becomes a ternary relationship among Employee, Department and Duration, and (Joe, Toys, 2015–2016) and (Joe, Toys, 2019–…) are two instances: the "Binary or ternary?" of p. 73, answered once.

Employee Department Work_In4 ssn did from to (0,N) (0,N) one pair, one instance

Before: the period hangs on the pair

Employee Department Work_In4 Duration ssn did from to (0,N) (0,N) (0,N) now the pair can repeat

After: the period is an entity, part of the identity

Fig. 1. Page 75 redrawn in the course's notation, one identifier per entity shown (filled dots; from and to together identify a Duration). The slide's plain lines carry no constraint, so every leg is (0,N). Before, one instance per (employee, department); after, one per (employee, department, period).

Hold on to that sentence — "a relationship is identified by participating entities". It is the rule the dungeon table of the warm-up breaks.

Where an attribute lives

Page 76, "Entity vs. Relationship", asks the second question through a budget. Each manager receives a discretionary budget, dbudget, and the first diagram hangs it on the relationship Manages2, next to since. The slide approves that drawing for one reading only: "First ER diagram OK if a manager gets a separate discretionary budget for each dept."

Change one fact — "What if a manager gets a discretionary budget that covers all managed depts?" — and the same drawing goes wrong twice:

The fix, in the slide's box "This fixes the problem!", is a subclass: Manager ISA Employee carries dbudget, and Manages2 now links Manager and Department and keeps only since, which really does depend on the pair.

Employee Department Manages2 ssn did since dbudget (0,N) (0,1) budget copied per dept

Before: dbudget on the relationship

Employee Manager Department Manages2 ssn did since dbudget (P,E) (0,N) (0,1) dbudget stored once

After: dbudget on the subclass Manager

Fig. 2. Page 76 in the course's notation. The slide's arrow from Department into the diamond is the lecture's "at most one" — (0,1) next to Department; plain lines are (0,N). The ISA triangle of the slide prints no pair: (P,E) is ours, since only some employees manage.

An attribute lives on the element whose instance alone determines its value; anywhere else it is copied, and misread.

Two remarks. The subclass has both "Reasons for using ISA" of p. 72 (lesson 6): "To add descriptive attributes specific to a subclass" — dbudget — and "To identify entities that participate in a relationship" — only managers manage. And the same question — where is this value determined? — is what moves the dungeon's multiplier in the last section.

A whole schema, and three ways to build one

Page 77, "E-R Example", is a complete schema in the course's own notation: the training company of the textbook the slides are taken from (Atzeni and colleagues — background, not on the slide). Nine entities, ten relationships, and every (min,max) pair sits next to the entity it counts: in how many instances of the relationship one instance of that entity takes part (lesson 6). Reading it aloud, relationship by relationship, is the drill every exam diagram needs.

The training company (p. 77), read aloud: each pair is read from the entity it stands next to.
Relationship and its two pairsIn words
CURRENT EMPLOYMENT (StartDate)
EMPLOYER (0,N) · EMPLOYEE (1,1)
An employer employs any number of employees now, possibly none; each employee has exactly one current employer.
PAST EMPLOYMENT (StartDate, EndDate)
EMPLOYER (0,N) · TRAINEE (0,N)
Any number in both directions.
EMPLOYMENT DATA
TRAINEE (0,1) · EMPLOYEE (1,1)
A trainee has at most one employment record; each record belongs to exactly one trainee, which also identifies it.
PROFESSIONAL DATA
TRAINEE (0,1) · PROFESSIONAL (1,1)
The same pattern for the professional record.
ATTENDANCE (Marks (0,1))
TRAINEE (0,N) · COURSE EDITION (1,N)
A trainee attends any number of editions; every edition has at least one trainee; a mark may be missing.
COMPOSITION
CLASS (1,1) · COURSE EDITION (1,N)
Every class belongs to exactly one edition; every edition has at least one class.
TYPE
COURSE EDITION (1,1) · COURSE (0,N)
Each edition is an edition of exactly one course; a course may have no edition yet.
TEACHING
COURSE EDITION (1,1) · INSTRUCTOR (0,N)
One instructor per edition; an instructor may teach none or many.
QUALIFICATION
COURSE (1,N) · INSTRUCTOR (1,N)
Every course has at least one qualified instructor; every instructor is qualified for at least one course.
HOLDER
TELEPHONE (1,1) · INSTRUCTOR (1,N)
Each number belongs to exactly one instructor; each instructor has at least one number.

TELEPHONE is p. 74's first test in action: several numbers per instructor, so an entity and the relationship HOLDER. Four symbols of p. 77 come from the textbook, unexplained on the slides: a black dot is an identifier (Code of TRAINEE); an arc with one dot across Time, Room and Date of CLASS is a composite identifier — one room at one time on one date is one class; a dot on a bar across the line of EMPLOYMENT DATA is an external identifier — an EMPLOYEE record is identified through its trainee; a (0,1) on an attribute's stem makes it optional, like Marks. The exam papers list the attributes under the diagram and underline the keys; only the paper of 30 Jan 2026 draws them on the diagram, a filled dot for each key.

Three strategies

How does a designer get from a text to such a schema? Pages 78–83, "ER Design Methodology", answer with three pictures, two tables and no prose; the explanations below are the textbook's.

Top-down Specifications Initial Intermediate Final schema Bottom-up Specifications C1 Cn … S1 Sn Integration Final schema Inside-out Employee Project Department Branch oil stain
Fig. 3. The pictures of pp. 79, 81 and 83, redrawn small: refine one schema of the whole; design components (C), one schema (S) each, and integrate them; grow from the central concept ring by ring — Employee, then Project, Department and Branch.
The primitives as the two tables print them (pp. 80 and 82).
Top-down primitives (p. 80)Bottom-up primitives (p. 82)
T1 From one entity to two entities and a relationship between themT1 Generation of an entity
T2 From one entity to a generalizationT2 Generation of a relationship
T3 From one relationship to multiple relationshipsT3 Generation of a generalization
T4 From one relationship to an entity with relationshipsT4 Aggregation of attributes on an entity
T5 Adding attributes to an entityT5 Aggregation of attributes on a relationship
T6 Adding attributes to a relationship—

Top-down T2, "From one entity to a generalization", is what Manager did to Employee. Top-down T4, "From one relationship to an entity with relationships", replaces a relationship by an entity of its own: the dungeon will need it in the last section. Duration was a different cure for the same illness: p. 75 keeps Work_In4 and adds a third participant.

On a text the size of the session's exercises, inside-out keeps you oriented: start from the entity the first sentence is about, then follow the verbs outward.

What a diagram cannot say

Page 73 ends with a warning: "A lot of data semantics can (and should) be captured. But some constraints cannot be captured in ER diagrams." The exam papers write such constraints in a line under the diagram that starts with N.B. The restaurant paper (6 Sept 2024) draws Table 1:N — Serve — 1:N Waiter and adds "Tables are served by more Waiters overall, but only one at a time": the pairs count every instance the relationship ever holds, and no pair can say "at a time". The Netflix paper (21 Jan 2025) adds "Only the original digital content can be dubbed", a condition on an attribute value, not a count. The Formula 1 paper (11 Feb 2025) writes "Each Team Member might have worked for different Teams in different periods of time" — Joe's problem again.

From text to diagram: the car rental

Exercise 1 of the session (p. 1293) is a one-paragraph requirements text: "Design an ER Model for a car rental system that manages the customers, the cars and their related elements." Customers show an ID card, a driving licence and a credit card, cars are inspected, rentals produce invoices. Read the solution slides in order (pp. 1294–1298) and a method shows through; this notebook splits it into five passes over the text, each leaving its own mark:

  1. Nouns. Things with an identity of their own — with facts to keep or, like the customer, with links to everything else — become entities; p. 1294 prints them in capitals and colour.
  2. Attributes. The facts in parentheses, or after "described by", become attributes of the entity they describe.
  3. Keys and assumptions. Underline what identifies each entity; where the text gives nothing, invent an identifier and write the assumption next to it.
  4. Verbs and quantity words. A verb between two entities becomes a relationship; "each", "their", "the list of all" become (min,max) pairs.
  5. The process out. What the system does is not what it stores: drop the steps, keep only their data footprint.

Five passes over the car-rental text

The text of p. 1294 on the left, the diagram it produces on the right, the attributes listed under it as the exam papers list them. Press Next: each pass adds one kind of mark to the text and one layer to the diagram, and the highlighter shows what the pass added. The one thing to see: only facts reach the diagram — the last pass strikes out a third of the text and the drawing does not move.

  1. Before pressing Next: besides the eight things that become entities, the text names a company (the one that inspected the car) and a list of vehicle categories. Predict what each becomes. Then go to pass 1.
    What you should see

    Neither gets a box. The company is only a name, one value with nothing inside: the attribute Company Name of Car Inspection. The vehicle categories are a short fixed list of yes-or-no facts about one licence: the composite attribute Drives. Both pass the two tests of p. 74 as attributes.

  2. Go to pass 3. How many identifiers does the text supply, and how many must the designer invent? Count before you look at the dashed rings.
    What you should see

    Three come from the text (the 9-digit ID, the 10-digit drive license number, the 16 digit number); five are invented — License Plate, Inspection ID, Operation ID, Rental Invoice ID and the customer's E-mail, the last with the slide's own "Assumption" (p. 1297).

  3. Pass 4 draws Credit Card (1,1) — Owns — (1,N) Customer. Before reading the answer: how many customers can own one credit card?
    What you should see

    Exactly one. The pair next to Credit Card counts a card's participations: (1,1), one owner, never none. The (1,N) next to Customer says a customer has one or more cards.

  4. Pass 5 strikes out the process. One step of it is not struck out: which one, and what does it leave in the model?
    What you should see

    "marks the rental invoice as “closed”", framed in a dashed box: its footprint is the attribute Status of Rental Invoice. Showing the list of cars, the 3-month check, handing over the keys (car keys, not identifiers) and the charge leave nothing — the check is a query over the inspections' Date.

Exercise 1, entity by entity (pp. 1295–1297): the identifier underlined (listed first here), and where it comes from.
EntityAttributes · origin of the identifier
Customer ID CardID, Name, Surname, Birth Date, Address, Release Date, Expiration Date
the text: "9-digit ID"
Driving LicenseDrive License Number, Name, Surname, Birth Date, Release Date, Expiration Date, Drives (Truck, Cars, Bus, …)
the text: "10-digit drive license number"
Credit CardIdentifier Number, CVC, Expiration Date
the text: "16 digit number"
CarLicense Plate, Brand, Price per Day, Maximum Speed, Fuel Consumption
added: a car's natural identifier, not in the text
Car InspectionInspection ID, Date, Company Name
invented: a date and a company need not be unique
OperationOperation ID, Description
invented, like the description
Rental InvoiceRental Invoice ID, Rental Date, Rental Period, Final Price, Status
invented; Status is the footprint of "closed"
CustomerE-mail
"Assumption: Customer is identified through an E-Mail"

Five identifiers out of eight are the designer's. The customer is the extreme case: the text gives the customer no attribute at all — every personal datum sits on the ID card — so the assistants invent one, circle it in red and write "Assumption: Customer is identified through an E-Mail" (p. 1297). Copy the habit. An invented key, or your reading of an ambiguous sentence, goes on the paper as "Assumption: …": a choice that is written down can be accepted, a silent one can only be wrong.

Page 1298 draws the customer half of the diagram. Read each pair from its own side: Credit Card (1,1) — Owns — (1,N) Customer gives each card exactly one owner and each customer one or more cards; the two other Owns, (1,1) on both legs, give every customer exactly one ID card and one licence. The other half exists only as a link (p. 1309), so the dashed part of the widget is one possible completion, not the assistants'. Its open choice is Operation: a kind of work that recurs across inspections gives Car Inspection (1,N) — Includes — (1,N) Operation; a line of a single inspection takes (1,1). Say which you mean.

And then: tables

The exercise closes with "N.B. ER models will be then mapped on tables that will contain data." and two tables (p. 1299):

Exercise 1 - Tables (p. 1299): the slide colours each licence plate, red for the Citroen, blue for the Ferrari.
License PlateFuel ConsumptionMax SpeedPrice Per DayBrand
AF012CG20 Km/l135 Km/h50€Citroen
DG186HF10 Km/l320 Km/h2’000€Ferrari
Inspection IDDateCompany NameLicense Plate
101/05/2021Tires & Co.AF012CG
201/08/2021FerrariDG186HF

The plate appears twice: as the key of a car, and inside each inspection row. That is the relational form of Car (0,N) — Undergoes — (1,1) Car Inspection: every inspection concerns exactly one car, so the car's key travels into the inspection's row, never the other way. Which key travels where is the recipe of lesson 8. Notice also what is missing: the "3 months" of the text — the check is a query over Date.

Museums and dungeons: derive, specialise, collapse

The second text of the session (p. 1302) is the Dutch Museum Association: museums, halls, artworks, artists, visitors, tickets and a shop. One deck prints it again under the assistant's red pen (p. 1328): boxed nouns, underlined identifiers, a small composite-attribute sketch beside "location", "only one artist" boxed as a cardinality hint. One placement repeats the rule of section 2: "Visitors state the time when they would visit the museum when they buy tickets", so Visiting Time hangs on Buy, the purchase that fixes it (p. 1306).

Two hierarchies, each with a reason

Extra II (p. 1305) grows the shop: "now museums will include three different kinds of shops: restaurant, sweets shop, and gadgets shop. While the first two shops sell food, the latter sells gadgets. Sweet shops only sell sweets. Food is described by the same attributes as gadgets, plus an expiry date."

Shop Product Gadgets Shop Restaurant Sweets Shop Gadget Food Sweet Sell Sell Sell 1:N 1:N 1:N 1:N 1:N 1:N (T,E) (T,E) (P,E)
Fig. 4. Museum Extra II (p. 1306), the additions redrawn. One Sell per kind of shop: Sweets Shop is linked to Sweet only, so "Sweet shops only sell sweets" needs no extra sentence. The 1:N labels are the slide's; the pairs in handwriting are ours — the slide prints none. Visitors still buy any Product (not drawn).

Each hierarchy has a reason. Product exists because food and gadgets share attributes: the shared ones go up, Expiry Date stays on Food — the first reason for ISA on p. 72, "To add descriptive attributes specific to a subclass". The kinds of shop exist because each sells a different kind of product through its own Sell — the second reason. Sweet has no attribute of its own; it exists to be the far end of the sweets shop's Sell.

"The slide draws the hierarchies without a pair, so the pair is optional." None of the three hierarchies of p. 1306 carries one, but the exam diagrams print a (T/P, E/O) pair on nearly every hierarchy (the restaurant paper of 6 Sept 2024 is the exception). Write yours, as a reading of the text: every shop is one of the three kinds, (T,E); every product is food or a gadget, (T,E); only some food is sweet, (P,E).

Keep it or derive it?

The dungeon text (pp. 1310–1311) describes players, characters, items, weapons and monsters; its solution opens with two red remarks (p. 1312). "Not all the data is useful": the password and e-mail confirmations check a form, they are not facts to store. "Do not forget the “Gold” attribute": the text only says gold "is provided to the player" when a monster is defeated, yet an amount that accumulates must live somewhere — the solution puts it on Character.

Then the session asks whether some attributes should be stored at all. Strength Score is "derived from the strength of the items equipped", and the slide's chain reads "It can be derived from “Weapons”" → "Redundancy" (p. 1314). A value you can compute from stored data is a derived attribute: storing it keeps two copies of one fact that can drift apart. The slide's next question, "What if the “Strength Score” would depend also on the “Experience Points”?", changes nothing: Experience Points are stored too. Page 1315 pushes on — "Can we remove “Gold” and “Experience Points” based on the same statement we made before?" — and prints both answers, each with its assumption:

Keep or derive (pp. 1314–1315): the verdict follows from what is recorded, under a stated assumption.
AttributeRecomputable from stored data?Decision
Strength Scoreyes: from the strength of the equipped weapons (and the stored Experience Points, if it depends on them)derive: "Redundancy"
Experience Pointsyes, if they only grow: the experience provided by the monsters slain, which the model records"Yes, they can be derived." — "Assumption: “Experience Points” are only earned."
Goldno, if it also shrinks: what a character spends is not recorded"No, they should be kept." — "Assumption: “Gold” can be spent."

Derivable means computable from what is recorded, and what is recorded depends on how you read the text — so the slide writes the assumption next to each verdict. Do the same.

When a subclass earns its place

In Extra III a bug lets players "equip weapons regardless of the class of their character, but they can only equip one weapon", and a "Weapon Efficiency Score" gives each weapon a multiplier against misuse (p. 1319). Page 1320 draws one Wield for everybody, Character (1,1) — Wield — (0,N) Weapon, makes the score a composite attribute of Weapon with one component per class, circles both hierarchies and asks "Is it still necessary to keep the ISA Hierarchies?" — "They can be transformed into attributes". With their wielding rules gone, the classes have nothing of their own: they collapse into an attribute Class of Character, the weapon kinds into an attribute of Weapon.

Extra IV runs the argument backwards. Developers start to play; they "have the same attributes of players, although they have a special tag named “DEV” associated with their account" (p. 1321), so the slide draws a Developer subclass, "OR" a Developer attribute — both work, and the attribute is simpler. Then "allowing players to add developers to their friends is not a good practice" (p. 1322): one kind of player now has a relationship the other must not have.

Player Player Identifier Developer Befriend (0,N) (0,N) a tag is enough

Before (p. 1321): developer as an attribute

Player Player Identifier Basic Player Developer (T,E) Befriend (0,N) (0,N) basic players only

After (p. 1322): the subclass has a relationship of its own

Fig. 5. Extra IV of the dungeon. A developer with nothing of their own is a tag; once Befriend must stay among basic players, the hierarchy (T,E) is needed and Befriend attaches to Basic Player — the rule becomes part of the structure.

A subclass earns its place with an attribute or a relationship of its own; without one, it is an attribute of the parent.

The structural fix has a price: Befriend now exists only among basic players, so developers cannot befriend each other either — more than the text asked. If that matters, it is exactly the kind of constraint that goes into an N.B. line.

Two more cases go through the same test. Boss Monster (p. 1313) fails it — no attribute or relationship of its own, only larger values — yet the slide keeps the subclass, (P,E); a Yes/No attribute would do as well. The museum's Extra III (p. 1307) passes it: "painters only befriend other painters and sculptors only befriend other sculptors". No solution is printed, but the device of p. 1322 gives one: Painter and Sculptor under Artist, (P,E) if other artists exist and nobody is both (state it), each with its own recursive Befriend.

Monster or fight? When a relationship must become an entity

Back to the warm-up. Extra I (p. 1316) introduces the "Killing Blow", which "awards the player that kills the monster with extra experience points, based on a “Monster Killing Blow Multiplier” score (between 1.2 and 1.5)". That multiplier belongs to the kind of monster, so the solution puts KB Multiplier on Monster, and a relationship Slay, (0,N) on both sides, counts Slain Amount and KB Amount for each pair.

Extra II (p. 1317) rebalances the game: the multiplier is now "between 0.5 and 1.5" and "assigned depending on how well the player fought the monster". Its value is fixed by the fight, so — the rule of p. 76 — it leaves Monster and joins KB Amount on a second relationship, Killing Blow. The slide asks "Should I keep them both?" and p. 1318 prints two answers: "Yes - From a data perspective, we can only keep “Killing Blow” even though the name of the relationship would change drastically. Therefore, we could assume we keep slay and add a simple “Slay Modifier”." and "No - We should keep them both for clarity of their meaning and for text coherence." Read each label by its text: "Yes" argues for one relationship, "No" for two. Both are printed, so argue yours: an ordinary kill is a killing blow with multiplier 1.0, the row circled "Standard Kill".

Where does the attribute live?

Three attribute ovals hang on Character, on Killing Blow or on Monster. Drag an oval onto another element, or tap it and then tap the element; with an oval focused, the keys 1, 2, 3 send it to Character, Killing Blow, Monster. Below the diagram, the tables show what the design can hold for three killing blows of Axel on the Goblin, one with each multiplier of p. 1318 (the dates and the Goblin's values are ours). The one thing to see: a relationship holds one instance per pair of participants, so only an entity can keep three fights between the same two.

  1. The widget opens on the slide's design: KB Multiplier on the relationship Killing Blow, with a Date of each kill beside it. Predict how many of the three killing blows it can store, then read the tables.
    What you should see

    One of three. The second and third rows have the same participants, (Axel, Goblin), so they are not new instances: their multipliers 1.5 and 1.0 and their dates are lost. This is the table of p. 1318 meeting the rule of p. 75.

  2. Turn on "Killing Blow as an entity". What changes in the diagram, and in the table?
    What you should see

    The diamond becomes a box linked to Character through By and to Monster through On, (1,1) on its side of both. In the table every row gets its own identifier, KB1 to KB3, with its own multiplier and date: 3 of 3 stored. That is top-down primitive T4 of p. 80.

  3. Keep the entity and switch the rule to Extra I, where the multiplier belongs to the monster. Before looking: is anything lost now? Where should the oval go?
    What you should see

    Nothing is lost, but the Goblin's 1.3 is copied into every killing blow — redundancy, and a design that suggests the value depends on the fight: the dbudget problem of p. 76. Drag KB Multiplier onto Monster and it turns green.

  4. Drag Difficulty Score onto Character. What does the verdict say, and why is it not merely a question of style?
    What you should see

    Red: the score describes the Goblin, not Axel. With one goblin it seems to work, but the day Axel fights a dragon there is no single value to write in his row.

That answers the warm-up: the sentence was p. 75's "a relationship is identified by participating entities". The cure is top-down primitive T4, "From one relationship to an entity with relationships": as an entity, three killing blows are three instances that may share a character and a monster. Turning a relationship into an entity is called reification (the textbooks' word, not the slides'); Work_In4 took the other cure, a third participant — both give each repetition an identity of its own. The museum's Extra I (p. 1304) needs the same if one artwork can be lent to the same museum twice: "keep track of the period each artwork spends in each museum" — one loan, one entity.

The exam papers keep their relationships binary and state such situations in words, like the Formula 1 "N.B." of section 3: spot them before you design the graph or the documents of the later exercises.

Exam-style questions

Theory questions in the form of the written exam — open answers of a few sentences, closed ones where a wrong answer may carry a penalty — and two exercises on ER fragments of past papers. In the nine past papers no exercise asks you to draw an ER diagram: every practical exercise starts from a given one, and its N.B. lines are where the design trouble hides.

Explain how you decide whether a concept should be modelled as an attribute or as an entity in an ER diagram. Use the address of an employee as the example.

Show model answer

It depends on how the information is used and on the semantics of the data. An attribute holds one atomic value for its owner. If an employee can have several addresses, address must be an entity connected to Employee by a relationship, because attributes cannot be set-valued. If the structure of the address matters — for example, we want to retrieve the employees who live in a given city — address must also be modelled as an entity, because attribute values are atomic. If neither holds (one address, always used as a whole), an attribute is enough. The same reasoning applies to attributes of relationships: since a relationship instance is identified by its participating entities, several values for the same pair (two working periods of one employee in one department) require a new entity, such as Duration.

A complete answer gives the two tests with their reasons — "set-valued" and "atomic" are the slide's words — and the decision for each case. The last sentence shows that you see the same rule behind p. 75.

True or false: in an ER diagram, a relationship Works_In between Employee and Department with the attributes from and to can record that the same employee worked in the same department in two different periods.

  • True The attributes describe one instance, and there is only one instance per (employee, department) pair.
  • False "A relationship is identified by participating entities" (p. 75): a second period of the same pair would be the same instance. The lecture adds an entity Duration and makes the relationship ternary.
Show model answer

False. A relationship instance is identified by its participating entities, so there is at most one instance for a given employee and department, with one value of from and to. Several periods require a new entity (Duration) and a ternary relationship.

A true/false with a possible penalty: the trap is that attributes look like they could repeat. They cannot — they hang on the pair.

Describe the top-down, bottom-up and inside-out strategies of conceptual design, and give one primitive of each of the first two.

Show model answer

Top-down: start from a single, abstract schema that covers the whole specification and refine it step by step — initial schema, intermediate schemas, final schema — each step replacing a concept with a more detailed structure; a primitive is "from one entity to two entities and a relationship between them" (others: to a generalization, from one relationship to multiple relationships or to an entity with relationships, adding attributes). Bottom-up: split the specification into components and sub-components, design a schema for each, then integrate the schemas into the final one; a primitive is "generation of an entity" (others: of a relationship, of a generalization, aggregation of attributes on an entity or a relationship). Inside-out: start from the most important concept and grow the schema outward, adding at each step the concepts directly connected to those already present, like an oil stain.

The slides give these strategies as pictures only (pp. 79–83), so explain the mechanism in your own words: refinement, integration, growth from a core. Remember that the bottom-up table is printed under the title "Top-down primitives".

Which of the following are primitives of the bottom-up strategy? Select all that apply.

  • Generation of a relationship Bottom-up T2 (p. 82).
  • Aggregation of attributes on an entity Bottom-up T4: loose attributes are gathered on an entity.
  • From one relationship to an entity with relationships Top-down T4 (p. 80): it refines an existing relationship.
  • Generation of a generalization Bottom-up T3.
  • From one entity to two entities and a relationship between them Top-down T1: it refines an existing entity.
Show model answer

Generation of a relationship, aggregation of attributes on an entity, generation of a generalization. The other two refine an existing concept and belong to the top-down strategy.

Rule of thumb: "generation" and "aggregation" build up (bottom-up); "from one … to …" refines (top-down). The bottom-up rows are printed under the title "Top-down primitives" (p. 82): know the printed title, and classify by the verbs.

In the role-playing-game exercise, a Character has Gold, Experience Points and a Strength Score derived from the strength of the equipped items. Which of these attributes would you keep in the ER model, and why?

Show model answer

An attribute whose value can be computed from data already stored is a derived attribute: storing it is redundant and can become inconsistent. Strength Score can be computed from the strength of the weapons the character wields, so it can be removed; it stays derivable even if it also depends on the Experience Points, since those are stored too. Experience Points can be derived under the assumption that they are only earned: they are then the sum of the experience provided by the monsters the character has defeated, which the model records. Gold must be kept under the assumption that it can be spent: spending is not recorded, so the current amount cannot be recomputed. The decision depends on these assumptions, which must be stated.

Three marks: the definition (derived = computable from stored data, hence redundant), one verdict per attribute, and the assumptions — the slides print both "Yes, they can be derived" and "No, they should be kept", each with its assumption.

On the ER diagram of the exam of 11 Feb 2025 (Formula 1 races). Consider this fragment of the diagram: Team Member 1:N — Include — 1:N Team, where Include has the attributes Hiring_Date and Resignation_Date, and the note "N.B. Each Team Member might have worked for different Teams in different periods of time." (a) State the two cardinalities in words. (b) Can the diagram record a mechanic who worked for the same team twice, in two different periods? (c) If not, change the conceptual design so that it can, and give the resulting entities, relationships and cardinalities.

Show model answer

(a) Each team member is included in at least one team and possibly many; each team includes at least one team member and possibly many.

(b) No. A relationship instance is identified by its participating entities, so Include contains at most one instance for the pair (mechanic, team), with one Hiring_Date and one Resignation_Date.

(c) Turn Include into an entity, Employment (Employment_ID, Hiring_Date, Resignation_Date), with Team Member (1,N) — Hold — (1,1) Employment and Employment (1,1) — In — (1,N) Team. Each period is now its own Employment instance, so the same member and team can appear in several periods. Equivalently, add a Period entity identified by Hiring_Date and Resignation_Date and make Include ternary, as the lecture does with Duration.

Part (b) is the point of the N.B.: the diagram alone cannot hold the situation the note describes. In (c), check that the new entity is (1,1) towards both old ones — every employment belongs to one member and one team. The paper itself does not ask (c); its MongoDB exercise asks for a documental representation of Team and of the team members, and that is where the N.B. bites: an array of periods inside each member can list the same team twice (lesson 13).

On the ER diagram of the exam of 6 Sept 2024 (restaurant). The diagram contains Table 1:N — Serve — 1:N Waiter, and the paper adds: "N.B. Tables are served by more Waiters overall, but only one at a time." Explain what the cardinalities express and why the paper needs the N.B. line.

Show model answer

Table 1:N means that each table is served by at least one waiter and possibly many; Waiter 1:N, that each waiter serves at least one table and possibly many. Cardinalities count all the instances of the relationship, whenever they hold, so they cannot say that at any given moment a table has only one waiter: that is a constraint over time. A lot of data semantics can be captured in an ER diagram, but some constraints cannot; they are stated in text, as in this N.B. line, and must be enforced by the database or by the application.

Two things make the answer complete: each pair read from its own side, and the link to p. 73, "some constraints cannot be captured in ER diagrams".

Check yourself

An instructor can have several telephone numbers, and each number belongs to one instructor. How does the schema of p. 77 model them?

  • As an attribute Phone of INSTRUCTOR An attribute holds one value; several numbers per owner fail the first test of p. 74.
  • As an entity TELEPHONE linked by HOLDER, with (1,1) next to TELEPHONE and (1,N) next to INSTRUCTOR Several values per owner make an entity. (1,1): each number has exactly one holder; (1,N): every instructor has at least one number.
  • As an entity TELEPHONE linked by HOLDER, with (1,N) next to TELEPHONE and (1,1) next to INSTRUCTOR The pairs are swapped: this says a number belongs to many instructors and an instructor has exactly one number.
  • As an attribute of the relationship TEACHING A number belongs to the instructor, not to an edition taught: wrong owner, and it would be repeated per edition.

Museum text: "Visitors state the time when they would visit the museum when they buy tickets." Ticket takes part in Buy with 1:1, Visitor with 1:N (p. 1306). Where can Visiting Time go without losing or repeating anything? Select all that apply.

  • On the relationship Buy The value is fixed by the purchase — where the slide puts it.
  • On Ticket Each ticket has exactly one purchase (1:1 on its side), so the attribute can move to Ticket without loss.
  • On Visitor A visitor buys several tickets with different times: one value per visitor would lose them.
  • On Museum A museum sells many tickets: its one value would be nobody's visiting time.

The (1,1) side can absorb a relationship's attributes — the same fact that, in lesson 8, lets a key travel into that table.

A manager's discretionary budget covers all the departments they manage. What is wrong with keeping dbudget on Manages2 (p. 76)?

  • The same value is stored once per managed department, and it suggests the budget depends on the manager–department pair The slide's two words: "Redundancy" and "Misleading". The fix moves it onto a subclass Manager.
  • Relationships cannot have attributes They can: since stays on Manages2, because it does depend on the pair.
  • A department could then have two managers "At most one manager" is a cardinality of Manages2; where dbudget sits does not change it.
  • dbudget would become part of the key of Manages2 A relationship is identified by its participants; descriptive attributes never join its identity.

Car-rental text. Which fragments leave no trace in the ER model? Select all that apply.

  • "the keys are provided to the customer" An action, not a fact to store — and car keys, not identifiers.
  • "the list of cars is shown to the customer" Showing is a query over Car; nothing new is stored.
  • "the system checks whether a car inspection has been performed in the last 3 months" A query over the inspections' Date; "3 months" appears nowhere in the model.
  • "the system marks the rental invoice as “closed”" Its footprint stays: the attribute Status of Rental Invoice (p. 1297).

You begin with the entity the whole project is about and, round after round, add the concepts directly connected to what you already have. Which strategy is this?

  • Top-down Top-down starts from one abstract schema of the whole and refines it.
  • Bottom-up Bottom-up designs separate components first and integrates them at the end.
  • Inside-out The oil stain of p. 83: EMPLOYEE first, then PROJECT, DEPARTMENT, BRANCH.

Developers are players with a "DEV" tag (p. 1321). When does a Developer subclass become necessary instead of an attribute?

  • Always: every kind of instance needs its own subclass Page 1321 offers the attribute as an equally valid option.
  • When developers get an attribute or a relationship of their own — as when players may no longer befriend them (p. 1322) Then (T,E) Basic Player / Developer lets Befriend attach to Basic Player only.
  • Never: subclasses only exist to add attributes The second reason for ISA on p. 72 is to identify the entities that participate in a relationship.
  • When there are more developers than basic players How many instances there are never decides the schema.

In Extra II the Killing Blow multiplier depends on how well the player fought. Why does the slide move it off Monster?

  • Its value is now determined by the fight, not by the kind of monster The rule of p. 76: an attribute lives where its value is determined. On Monster, one goblin would need many values.
  • Monsters cannot have numeric attributes Difficulty Score, Gold Score and Item Score are numeric and stay on Monster.
  • Because Boss Monster is a subclass of Monster The hierarchy plays no part: the change is about what determines the value.

Key take-aways

What to watch and read