Entity Relationship Diagrams

Entity Relationship Diagrams

Learning objective

11.2.2.2 create entity-relationship diagrams (ERD)

An entity-relationship diagram (ERD) shows the relationships between entities in a system and how they connect. 

1. Entities and relationships

The Coding club organises workshops for students. We want to model which students attend which workshops.

Entity

A type of person, object or concept about which the system stores information.

Examples: Students, Workshops.

Relationship

An association between entities. A verb often helps us describe it.

Example: Students attend Workshops.

Draw each entity as a named rectangle. Draw a line between related entities. Add one or many at each end, using the rules of the scenario.

Ask two questions: “How many workshops can one student attend?” and “How many students can one workshop have?”

2. A simple notation: one and many

We use a simplified Crow’s Foot notation. A single bar means one. A three-pronged foot means many. The marks show only the maximum number: one or many.

A single bar next to an entity means one. A three-pronged crow’s foot next to an entity means many.EntityOne (1)EntityMany (M or N)

The mark next to an entity counts that entity. For example, many next to Workshops means that one student can attend many workshops.

M and N both mean many. They can stand for different numbers. “Many” means that more than one is allowed; it does not mean that every student currently attends several workshops.

Relationship Read the rules in both directions
One-to-one (1:1) One on both sides.
One-to-many (1:M) One on one side; many on the other.
Many-to-many (M:N) Many on both sides.

On a small screen, scroll a diagram horizontally to see it in full.

3. Coding club: three relationships

A. Students attend workshops — M:N

  • One student can attend many workshops.
  • One workshop can have many students.
Students and Workshops have a many-to-many relationship. A student can attend many workshops, and a workshop can have many students.StudentsWorkshopsMNattend

There is many at both ends, so this is a many-to-many relationship.

B. Mentors lead workshops — 1:M

For this model, each workshop is led by one mentor.

  • One mentor can lead many workshops.
  • One workshop is led by one mentor.
Mentors and Workshops have a one-to-many relationship. One mentor can lead many workshops; each workshop is led by one mentor.MentorsWorkshops1Mlead

Read from Mentors to Workshops: one-to-many. Read in the opposite direction: many-to-one. This is the same relationship viewed from the other end.

C. Students have club cards — 1:1

For this model, we consider each student’s current club card.

  • Each student has one current card.
  • Each card belongs to one student.
Students and Club cards have a one-to-one relationship in this model. Each student has one current club card; each card belongs to one student.StudentsClub cards11have

There is one at both ends, so this is a one-to-one relationship.

Use the stated rules. If workshops could have several mentors, the Mentors–Workshops relationship would change to M:N.

ERD builder (online)

4. Other examples

Shanyrak teams and students

In this model, a Shanyrak team includes many students, and each student belongs to one team. This is 1:M from teams to students.

One Shanyrak team can include many students; each student belongs to one team. This is a one-to-many relationship.Shanyrak teamsStudents1Minclude

Library borrowing over time

A member can borrow many physical book copies over time. The same copy can be borrowed by different members at different times. For the whole borrowing history, the relationship is M:N.

Over time, one member can borrow many book copies, and one book copy can be borrowed by many different members. This is a many-to-many relationship.MembersBook copiesMNborrow over time

State the time frame. This diagram describes borrowing over time, rather than who holds a copy at this moment.

5. Relationship laboratory

Change the proposed rules. The diagram shows only entities and one/many marks. These controls do not change the examples above.

Interactive checks are loading. If this message remains, use the explanations and model answers.

Current diagram: many-to-many (M:N).

The mark beside Students shows students per workshop. The mark beside Workshops shows workshops per student. Only one and many are used.StudentsWorkshopsMNattend

Many-to-many (M:N). One student can attend many workshops, and one workshop can have many students.

Explain: Which mark counts students? Which mark counts workshops? Read each new diagram in both directions.

Exercises

Exercise 1. LearningApps

Complete the original true/false activity.

Exercise 2. LearningApps

Identify the entities in the given statements.

Completed: 0 / 6 checked activities (Exercises 3–8).

Practice checks run on this page. Progress resets when you reload. LearningApps has its own checks.

Exercise 3. Identify the entities

The Coding club wants to show which students attend which workshops. Select the two entities.

The entities are:

 

Explanation / model answer

Students and Workshops are the entities. Attend describes the relationship between them.

Exercise 4. Choose the relationship type

Use the rules given in each scenario.

 

Explanation / model answer

Students–Workshops: M:N. Mentors–Workshops: 1:M. Students–Club cards: 1:1. Check the rule in both directions before choosing.

Exercise 5. Read both directions

Use the Mentors–Workshops diagram from the Coding club example.

 

Explanation / model answer

One mentor can lead many workshops; one workshop has one mentor. The mark next to Workshops counts workshops. The mark next to Mentors counts mentors.

Exercise 6. Change a business rule

The club now keeps all cards issued over time, including replaced cards. One student can have several cards in this history; each card belongs to one student.

 

Explanation / model answer

The relationship becomes Students 1:M Club cards. Put one next to Students and many next to Club cards. The old rule was about one current card; the new rule includes all cards issued over time.

Exercise 7. Set the time frame

A library member can borrow several physical book copies. For this model, each borrowed copy is held by one member at a time.

 

Explanation / model answer

Current borrowing: 1:M from Members to Book copies. Borrowing history: M:N. Over time, a member can borrow several copies, and a copy can be borrowed by several different members. State the time frame before drawing the diagram.

Exercise 8. Draw an ERD

A Shanyrak team can take part in several activities. Each activity can include several teams. Draw the ERD on paper, then check your decisions below.

 

Explanation / model answer

Use two entity rectangles, Teams and Activities, with many at both ends of the connector: M:N.

One team can take part in many activities; one activity can include many teams. This is a many-to-many relationship.TeamsActivitiesMNtake part in

Read it aloud: “One team can take part in many activities. One activity can include many teams.” The automatic check assesses your choices; compare your drawing with this model yourself.

Explain your diagram

Purpose Useful language
Identify entities The entities are … and …
Describe one direction One … can … many …
Describe the reverse direction Each … belongs to one … / One … can have many …
Justify the relationship This is a … relationship because …
  1. Explain the Students–Workshops relationship using two sentences, one for each direction.
  2. Explain how the Mentors–Workshops relationship would change if several mentors could lead the same workshop.
  3. Draw an ERD for Authors and Books. Use these rules: one author can write several books; one book can have several authors.
Model explanations

1. One student can attend many workshops. One workshop can have many students. This is a many-to-many relationship.

2. A mentor can lead many workshops, and a workshop can now have many mentors. The relationship changes from one-to-many to many-to-many.

3. Draw two rectangles labelled Authors and Books. Put many at both ends of the connecting line: M:N.

Check your ERD: name the entities, connect related entities, add one or many at each end, and explain both directions using the scenario rules.

Practice: Relational databases.

The Coding club, card, team and library scenarios are illustrative models. Follow the rules stated for each example.

Play: ERD Tetris — Catch the Relationship

Open the game in a separate window

Read the falling description and choose the matching relationship: 1:1, 1:M or M:N. Click inside the game before using keys 1, 2 and 3.

Open the game in a separate window

You can play here or use the link above for a larger view.

Категория: Relational databases | Добавил: bzfar77 (03.11.2020)
Просмотров: 12284 | Комментарии: 1 | Теги: Entity Relationship Diagram, ERD, One-to-One, Many-to-Many, One-to-Many | Рейтинг: 4.6/5
Всего комментариев: 1
avatar
0
1 zhaksylyknuraly251208 • 10:49, 07.10.2026
Хорошая тема.
avatar