3 ER Diagram
3 ER Diagram
1
CONTENT
■ ER MODEL DEFINITION
■ ENTITY
■ ATTRIBUTES
■ RELATIONSHIP
■ SYMBOLS
■ CARDINALITIES
2
Database Design
Requirements gathering and specifications
– provide you with a high-level understanding of
– the organization,
– its data, and
– the processes
that you must model in the database.
Database design
− involves constructing a suitable model of this information.
Types of DB Design
1. Conceptual Design/Logical Design- ER model
2. Physical design- Relational model
3
Conceptual Database Design
Modeling the collected information at a high-level
without using a particular DBMS.
4
Relation Instances
5
Relation Instances
Relation Instances
ER Model
ER Model Example
7
ERD Design Steps
1. Find the Entities from the problem statement
(Look for Nouns)
8
Entity Sets
■ An entity in an ER model is a thing in the real world, can be
– Physical (e.g. person, animal, place)
– Conceptual (e.g. event, company, job, university course)
stored as a record or a table row
Example: specific person, company, event, plant
An entity set is a set of entities of the same type that share the same
properties.
stored as a relation or a table
Example: set of all persons, companies, trees, holidays
9
Entity
Entity
Represents a group of real-world objects that have properties.
Does not always have to be a physical real-world object such as a
person or department,
it can be an abstract concept such as a project or job.
Stored as a relation or a table
Example: Person (Employee, Student), Department(Sales, Accounts
D), Place(Hospital, University), object or event, Project
Entity instance
is a particular example or occurrence of an entity type.
Ex: entity : Employee(Eid, Ename, Esal),
entity instance (1, ‘Hulk’, 5000).
10
1. Representing Entity
Entity are represented by rectangles with the name of the entity
in the rectangle.
Examples:
Find the Entities from the problem statement (Look for Nouns)
11
2. Relationship
Relationship
• is a set of meaningful associations/ connections among entities
• Each relationship is given a name that describes its function.
• Example:
• Employee works on Project, Teacher teaches Subject,
• Customer owns Account, Customer buys Cake, Doctor treats Patient
Relationship instance
is a particular occurrence of a relationship that relates entity instances.
Ex, WorksOn - relationship
Relationship instance : ‘Tony Stark' works on project ' End Game ‘
or (Tony Stark, End Game).
12
Representing Relationship Types
Name
13
Attributes
Property of an entity or a relationship.
Ex, entity Employee has attributes: name, salary, title, etc.
Represented as named ellipse
Rules:
1. attribute names begin with a lower case letter.
Attributes may be
02/23/202
Attributes Types (contd…)
A. Simple attribute
contains a single part.
Also called atomic attributes.
– Example, salary.
Represented by an ellipse
B. Composite attribute
consists of multiple components (subattributes) each.
– Ex: address consists of (street, city and state)
– Name consists of (?,?,?)
Represented as
hierarchy of ellipses
– splitting of the ellipse
into component ellipses
16
Attributes Types (contd…)
Composite Attributes
17
Single-Valued and Multi-Valued
Attributes
A. Single-valued attribute
consists of a single value for each entity instance.
Example: salary
B. Multi-valued attribute
Attribute may have multiple values for a single entity instance.
Ex:
a) Telephone number =(home phone number, cell phone number, etc.)
18
Derived Attributes
Derived attribute
Its value is calculated from other attributes
Its value is not physically stored.
Name
Represented by dashed ellipse
Example :
a) Age can be calculated from DOB
19
Keys
A candidate key is a minimal set of attributes that uniquely
identifies each instance of an entity type.
For example, the number attribute uniquely identifies an
Employee and is a candidate key for the Employee entity type.
A primary key is a candidate key that is selected to identify each
instance of an entity type.
The primary key is chosen from a set of candidate keys. For
instance, an employee may also have EmiratesID as an
attribute. The primary key may be either EmiratesID or number
as both are candidate keys.
A composite key is a key that consists of two or more attributes.
For example, a course is uniquely identified only by the course
code (22C) and the course number within the department (144).
identify the type of attributes
Example
22 Yan Huang - ER
02/23/202
Attributes in the ER Model Example
23
Class Activity
■ Draw an E-R Diagram for the following
statement. “Players has team and they
participated games.” / “Customer buys
novel creates by writer.”
24
■ ER
SYMBOL
S
25
ERD Design Steps
1. Find the Entities from the problem statement
(Look for Nouns)
26
Step 4: Relationship Cardinalities
■ Relationship cardinalities or multiplicities
■ multiplicity –
number of possible occurrences of an entity that
may relate to a single occurrence of an associated
entity.
30
a. One-to-One Relationship
Example
31
b. One-to-Many Relationships
■ each instance of an entity E1 can be associated with
■ more than one instance of another entity E2.
32
b. One-to-Many Relationship
Example
33
c. Many-to-Many Relationships
34
c. Many-to-Many Relationship
Example
35
37
■ ER
SYMBOL
S
38
ERD Design Steps
1. Find the Entities from the problem statement
(Look for Nouns)
40
Yan Huang - ER
02/23/202
Class Activity
■ Draw an E-R Diagram for the following
statement. “Players has team and they
participated games.” / “Customer buys
novel creates by writer.”
41
ER Design TASK
■ Construct an ER Model for a university database where:
– Each student has an id, name, birth date, and Grade /mark.
42
Task 2.a
43
REFERENCES:
Connolly, T.M. and Begg, C.E. (2015) Database systems: a practical
approach to design, implementation, and management. Pearson
Education.