Data Modeling Using The Entity-Relationship Model: Dr. Enosha Hettiarachchi
Data Modeling Using The Entity-Relationship Model: Dr. Enosha Hettiarachchi
Relationship Model
Dr. Enosha Hettiarachchi
Database Design
The database design process can be broken down into
four phases.
Table
Table
ATTR2 A TTTR3 ATTRTR5
DBMS (product) 8
Database Design... Logical Design
Physical Design
This is the process of defining
structure that enables the
database to be queried in an
efficient manner.
E.g. index and hash file
design, data partition
9
Phases of Database Design
Mini-world
Requirements
Collection & Analysis
Functional
Database
Requirements
Requirements
Conceptual Design
Functional Analysis
High-level Transaction Conceptual
Specification Data Model
Logical Design
Application Program
Design Logical Data
Model
Transaction Physical Design
Implementation
Physical Data
Application Programs 10
Model
Types of Data Models
Table
ATTR2 AT TTR3 ATTR4
Table
employee(empno, …)
•A set of data structures assembled following rules
that describe the processing requirements (access
paths) of the data in terms of a logical database
model
• Done by a Data Analyst
• Not constrained by technology
Physical Data Model
create table Table
employee(empno …)
11
Systems Development Life Cycle (SDLC)
Project Project
Identification Initiation & Analysis
& Selection Planning
Physical Logical
Implementation Design Design
• Enterprise Modelling
• Conceptual Data Modelling
• Logical Database Design
• Physical Database Design and Creation
• Database Implementation
• Database Maintenance
Enterprise Modelling
Physical Design
22
Database Implementation
Implementation
23
Database Maintenance
Entity types
Relationship types
Attributes
21
Conceptual Design
24
Conceptual Design
25
Entity Type
26
A mini-world example
27
A mini-world example
28
A mini-world example
29
Entities
Conceptual Design
Entities
• Department
• Employee
• Project
• Dependent
31
Attributes
Attribute
A property or characteristic of an entity type that is of interest to the
organisation.
Simple Attribute
An attribute that cannot be broken down into smaller components.
– e.g. Emp No
Emp No
32
Attributes
Multi-valued Attribute {}
An attribute that may take on more than one value for a given entity instance
e.g. Employee Skills, Qualifications
Skills
Composite Attribute
An attribute that can be broken down into component parts
e.g. Address (Street, City, State, Postal Code)
Name (First Name, Middle Initials, Last Name)
33
Attributes
Stored Attribute
An attribute whose value is stored in the database
Derived Attribute
An attribute whose values can be calculated from related attribute values
e.g. Years Employed (using Employed Date)
Age (using Date of Birth)
Age
34
Key Attribute(Identifier)
Identifier
An attribute (or combination of attributes) that uniquely identifiers individual
instances of an entity type
e.g. Emp No
Employee Emp No
Composite Identifier
An identifier that consists of a composite attribute
e.g. Flight Id (Flight No, Date)
Flight No
Flight Flight Id
Date
35
Key Attribute (Identifier)
Choose an identifier that will not change its value over the life
of each instance of the entity type.
36
Initial Conceptual Design of the Company
Database
Department
Name, Number,{Locations}
Project
Name, Number, Location
Employee
Name(Fname, Lname), NID, Gender, Address, Salary,
BirthDate
Dependent
dependentName, Gender, BirthDate, Relationship
37
Conceptual Design
Notations
Entity
Relationship
Attribute
39
Conceptual Design
Attribute
Key Attribute
Multivalued attributes
Derived Attribute
Weak Entity
Identifying Relationship
40
Entity Types
Employee
Weak Entity
An entity types whose existence depends on some other entity
Dependent
41
Entity Types
Identifying Owner
– The entity type on which the weak entity type depends
e.g. Employee is the Owner of Dependent
42
Associative Entity
Certificate
Emp No Emp Name Date Comp Course Id CName
30 4
Employee Completes Course
4 30
Employee Certificate Course
Cert No
2 one to many relationship
Associative Entity
46
Relationships
47
Relationships
48
Relationships
Relationship Type
A meaningful association between (or among) entity types
Relationship Instances
An association between (or among) entity instances,
where each relationship instance includes exactly one
entity from each participating entity type
49
Degree of Relationship Type
Ternary Relationship
A simultaneous relationship among the instances of
three entity types
Supplier s supplies part p to project j
Part
Supplier Supplies
Project
51
Degree of Relationship Type
Quaternary relationship
1..1
1..1 1..1
1..*
Constraints on Relationship Type
53
1:1
1 1 Department
Employee manage
54
1:N
N 1 Department
Employee Works-for
55
M:N
M N Project
Employee Works-for
56
Constraints on Relationship Type
Department
manages
57
Constraints on Relationship Type
Partial Participation
The participation of Employee in manages relationship type is
partial.
Employee
manages
58
Detailed Conceptual Design
Unique
Dept No unique identifier of a dept. Identifier
Dept Name name of a department
Location location of a department
Multi-valued
Phone phone no. of a department
Employees no. of employees in a dept. Derived
Dept No
Dept Name
Department Location
Phone
Employees
Detailed Conceptual Design
First Name
Emp No
Mid Initials
Emp Name
Last Name
Employee NID
Address
Salary
Gender
DOB
ER Schema Diagram
1 N Locations
supervise N 1
supervisor supervisee works-for Name NoOfEmployees
61
Teaching Database
1 N
Professor teaches Section
Email
N
Salary First
Name Part of
Last
1
Number Course
Topic Name