1 of 36

Database Systems​

Fall 2025

Recitation 6

2 of 36

Agenda for Today

  • ERD Exercise
  • EER Reverse Engineering with MySQL Workbench

3 of 36

ERD – Entity-Relationship Diagrams

4 of 36

Conceptual and Logical Data Models

The logical data model describes the data in a much more detailed form than the conceptual data model.

5 of 36

Conceptual Data Model -�Least detailed

  • Defines WHAT the system contains​

  • Contains entities, relationships​

  • Uses diagrams to represent data​

  • The purpose is to define business entities and their relationship​

  • First step of data modeling

6 of 36

  • Defines HOW the system should be build​. For example: relational, No-SQL, …

  • Contains entities, relationships​, attributes, keys, constraints, types of attributes

  • Uses schema to represent data​

  • The purpose is to develop a technical view of the data structure​

  • Done after the conceptual data model

Logical Data Model – �More detailed

7 of 36

Conceptual Data Model -�Least detailed

  • Defines WHAT the system contains​

  • Contains entities, relationships​

  • Uses diagrams to represent data​

  • The purpose is to define business entities and their relationship​

  • First step of data modeling
  • Defines HOW the system should be build​. For example: relational, No-SQL, …

  • Contains entities, relationships​, attributes, keys, constraints, types of attributes

  • Uses schema to represent data​

  • The purpose is to develop a technical view of the data structure​

  • Done after the conceptual data model

Logical Data Model – �More detailed

ERD

8 of 36

Basic components

8

Entity sets

Attributes

Relationships between entities

Product

name

buys

Set: there can be many or no products, similar to a product table

Similar to a table column

We’ll see

9 of 36

Keys

Every entity set must have a unique identifier = key

9

Product

name

category

price

10 of 36

Example

10

buys

makes

employs

Company

name

category

stockprice

name

price

address

name

ID

Person

Product

11 of 36

A relation(ship)

If A, B are (entity) sets, a relation R is a subset of AxB

E.g., A = {1, 2, 3}, B={a, b, c, d}, R = {<1,a>, <1,c>, <3,b>}

11

1

2

3

a

b

c

d

12 of 36

A relation(ship)

If A, B are (entity) sets, a relation R is a subset of AxB

R = {< Mware, iPud17s >, < Mware, iPud17 >, < HC, iPudMini>}

12

Mware

Snapple

HC

iPud17s

iPudMini

iPud17

smartWatch

makes

Company

Product

13 of 36

Relationship multiplicity in E/R

one-to-one

many-to-one

many-to-many

13

1

2

3

a

b

c

d

1

2

3

a

b

c

d

1

2

3

a

b

c

d

14 of 36

Referential Integrity

made by

Company

Product

made by

Company

Product

At most one

Exactly one

15 of 36

Enhanced example

15

buys

made by

employed�by

Company

name

category

stockprice

name

price

address

name

ID

Person

Product

16 of 36

Attributes on relationships

16

buys

name

category

price

address

name

ID

Person

Product

date

17 of 36

Multi-way relationships

17

purchase: a subset of Product x Store x Person

Purchase

Product

Person

Store

date

18 of 36

Subclasses in E/R ("isa" relationship)

18

medicalHistory

specialty

ID

name

address

Patient

Physician

Person

isa

isa

Always one-to-one relationship, but we don’t draw the two arrows

19 of 36

Weak Entities

Company

Product

made by

number

price

address

name

An entity such that its identifier depends on another entity.

The entity and the dependence relationship are described with a double outline. 

20 of 36

Weak Entities

Company

Product

made by

number

price

address

name

  • The key "number" for the Product is not the complete key, it requires the "name" of the company 
  • The "made by" relationship is called a supporting relationship.
  • The "Company" entity set is called a supporting entity set.

Always use an exactly-one arrow with weak entities

21 of 36

Motivation for using Weak Entities

Company

Product

made by

number

price

address

name

made�by

Company

Product

number

price

address

name

Company name

Company name

22 of 36

Exercise

You are asked to design the database schema for a pizza company.  The data you need to address is as follows:

  • The pizza company has a chain of restaurants. Each restaurant has a unique address and a telephone number for orders. It also has a manager and a staff of employees, who all work there full-time. Each person employed by the pizza company is identified by his social security number (SSN) and has a name, address, telephone number, and salary.
  • The menu of all restaurants is the same and consists of various dishes - each identified by a unique name and has a certain price. Among the dishes, there are different pizza dishes. Each pizza dish has a unique topping and is prepared only by the manager of the restaurant. Other dishes are prepared by the employees
  • The customers of the chain are identified by their telephone number and are asked for their first name. The pizza company would like to keep track of the customers’ orders: Each order is done by a customer on a certain date, supplied by an employee, and has the quantities for each product that was ordered.

23 of 36

Exercise (1A)

You are asked to design the database schema for a pizza company.  The data you need to address is as follows: 

  • The pizza company
    • has a chain of restaurants. Each restaurant has a unique address, and a telephone number for orders. 
    • It also has a manager who is an employee and a staff of employees, who all work there fulltime. 
    • Each person employed by the pizza company is identified by his social security number (SSN), and has a name, address, telephone number and a salary.

24 of 36

Restaurant

Employee

address

ssn

name

salary

address

WorksIn

telNumber

Manager

Is a

ManagerOf

25 of 36

Exercise (1B)

You are asked to design the database schema for a pizza company.  The data you need to address is as follows: 

  • The pizza company has a chain of restaurants. Each restaurant has a unique address, and a telephone number for orders. It also has a manager and a staff of employees, who all work there fulltime. Each person employed by the pizza company is identified by his social security number (SSN), and has a name, address, telephone number and a salary.
  • The menu of all restaurants
    • is the same, and consists of various dishes 
    • Each dish identified by a unique name and has a certain price. Among the  dishes there are different pizza dishes with unique topping.
    • Each pizza dish is prepared only by the manager of the restaurant.

26 of 36

Restaurant

Employee

address

ssn

name

salary

address

WorksIn

telNumber

Manager

Is a

ManagerOf

Dish

name

Pizza

price

CookedBy

topping

Is a

27 of 36

Exercise (1C)

You are asked to design the database schema for a pizza company.  The data you need to address is as follows:

  • The pizza company has a chain of restaurants. Each restaurant has a unique address and a telephone number for orders. It also has a manager and a staff of employees, who all work there full-time. Each person employed by the pizza company is identified by his social security number (SSN) and has a name, address, telephone number, and salary.
  • The menu of all restaurants is the same and consists of various dishes - each identified by a unique name and has a certain price. Among the dishes, there are different pizza dishes. Each pizza dish has a unique topping and is prepared only by the manager of the restaurant. Other dishes are prepared by the employees
  • The customers of the chain are identified by their telephone number, and are asked for their first name.
  • The pizza company would like to keep track of the customers’ orders: Each order is done by a customer on a certain date, supplied by an employee, and has the quantities for each product which was ordered.

28 of 36

Restaurant

Employee

address

ssn

name

salary

address

WorksIn

telNumber

Manager

Is a

ManagerOf

Dish

name

Pizza

price

CookedBy

topping

Is a

Customer

Order

OrderedBy

telNumber

name

date

includes

quantity

DeliveredBy

29 of 36

From ER Diagrams to Relational DB

  • For most cases:
    • Turn each entity set into a relational table with the same set of attributes.
    • Replace a relationship with attributes or a relational table depending on the relationship type:
      • One-to-Many: an attribute in the many table (pointing to the one table FK)
      • Many-to-Many: a connection table (can have its own attributes)
      • One-to-One: an attribute in either table (it depends on the other relationships)
    • Rename attributes, if needed, to avoid name conflicts.

30 of 36

Exercise (2)

Convert the following ERD into Relational DB:

Restaurant

Employee

address

ManagerOf

ssn

name

salary

address

WorksIn

telNumber

31 of 36

Exercise (2)

Convert the following ERD into Relational DB:

Restaurant

Employee

address

ManagerOf

ssn

name

salary

address

WorksIn

telNumber

Employee(SSN, name, salary, address, worksInRestaurantAddress)

Restaurant(address, telNumber, managerSSN)

32 of 36

EER Reverse Engineering with MySQL Workbench

33 of 36

EERD

  • EERD – Enhanced Entity-Relationship Diagrams.
  • An enhanced version of ERD.
  • Include more features which enable a more precise representation of properties and constraints.

34 of 36

Data Model Reverse Engineering 

  • Reverse Engineering is the process of reconstructing a data model (for example ER model) from an existing schema.

  • May be useful in understanding a given database.

35 of 36

Reverse Engineering with MySQL Workbench

MySQL Workbench provides an interface for applying a logical EERD reverse engineering process.

  • In MySQLWorkBench:
    • Database -> Reverse Engineer

36 of 36

Some Properties of the MySQL Workbench EERD

Line styling meaning:

Attributes' icons meaning: