Entity relationship diagram: entities and relationship lines

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Entity relationship diagram: entities and relationship lines

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. In an ERD, how is each entity drawn?
A As a labelled box
B As a line between two shapes
2. What does a line joining two boxes in an ERD show?
A A copy of the data from one table to another
B A relationship between the two entities
3. Where are attributes written in an ERD?
A Listed inside the entity's box
B Written on the relationship line
4. Which label marks the primary key attribute in an entity box?
A PK
B FK
5. In the Orders box, studentId links back to the Students table. How should it be marked?
A PK
B FK

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1[students] box with studentId PK, firstName, house AOne entity drawn as a labelled box, with its attributes listed inside and the primary key marked PK
2[results] box with studentId FK, subjectId FK, mark B[students] ------ [orders]
3A relationship is drawn as a line joining two entity boxes C[students] --places-- [orders]
4The relationship line is labelled with a verb that says how the entities connect DThe foreign key fields are marked PK. They link to other entities, so they should be marked FK. The orders box needs its own PK, such as orderId.
5[students] [orders] (two boxes with no line between them) EAn entity box where the FK marks show which fields link to other tables
6[orders] box with studentId PK and productId PK FThere is no relationship line, so the ERD does not show that students and orders are related. Draw a line joining the two boxes.

Definitions

ERD

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
[Student] studentId __ firstName
2.
[Result] studentId __ mark
3.
[Student] ___ [Result]
4.
label = "places" [Student] --______-- [Order]
5.
Entity: Student [_______] studentId PK

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A [Student]
B studentId PK
C firstName FK
D houseId FK
Question 2
A [Student]
B [Subject]
C [Result]
D Student *--1 Result : sits
E Subject 1--* Result : has
Question 3
A [Result]
B resultId PK
C mark
D studentId PK
E Student 1--* Result : sits
Question 4
A [Order]
B orderId
C studentId FK
D productId FK
Question 5
A [lastName]
B teacherId PK
C lastName

Answer Key

Entity relationship diagram: entities and relationship lines
Section A: Quick Questions
Q1
A — As a labelled box
Q2
B — A relationship between the two entities
Q3
A — Listed inside the entity's box
Q4
A — PK
Q5
B — FK
Section B: Match the Pairs
Q1
[students] box with studentId PK, firstName, house → One entity drawn as a labelled box, with its attributes listed inside and the primary key marked PK
Q2
[results] box with studentId FK, subjectId FK, mark → An entity box where the FK marks show which fields link to other tables
Q3
A relationship is drawn as a line joining two entity boxes → [students] ------ [orders]
Q4
The relationship line is labelled with a verb that says how the entities connect → [students] --places-- [orders]
Q5
[students] [orders] (two boxes with no line between them) → There is no relationship line, so the ERD does not show that students and orders are related. Draw a line joining the two boxes.
Q6
[orders] box with studentId PK and productId PK → The foreign key fields are marked PK. They link to other entities, so they should be marked FK. The orders box needs its own PK, such as orderId.
Section C: Definitions
Q1
ERD — An entity relationship diagram draws each entity as a labelled box and each relationship as a line joining two boxes. Boxes list attributes, with PK and FK marked.
Section D: Fill in the Blanks
Q1
[Student] studentId PK firstName
Q2
[Result] studentId FK mark
Q3
[Student] --- [Result]
Q4
label = "places" [Student] --places-- [Order]
Q5
Entity: Student [Student] studentId PK
Section E: Spot the Error
Q1
C — FK marks a field that links to another table's primary key. firstName is an ordinary attribute, so it needs no mark. Only houseId should be marked FK.
Q2
D — One student can have many results, so the 1 goes on the Student end and the * on the Result end. The line should be Student 1--* Result : sits.
Q3
D — In the Result box, studentId points back to the Student table, so it is a foreign key. The Result's own primary key is resultId. The line should be studentId FK.
Q4
B — The attribute that uniquely identifies each order must be marked PK in the box. The line should be orderId PK.
Q5
A — Each box is labelled with the entity name, not an attribute. lastName belongs inside the box. The label should be [Teacher].