Lecture2 3new
Lecture2 3new
Systems I
Lecture 2 - 3
Objectives
Introduction to ER Modelling
Database Design
Requirements Analysis
Conceptual Database Design
Logical Database Design
Schema Refinement
Physical Database Design
Security Design
Requirements Analysis
This step answers the following question:
“What users want from the database?”
- What is going to be stored in the database?
- What applications are going to be built on top
the database?
- what are the most frequently asked queries?
Result:
A well-written concise document
enumerating the user’s requirements.
Requirement Analysis (contd.)
Eg. ER Model
Logical Database Design
Requirements gathering
ENTITY
WEAK ENTITY
RELATIONSHIP
IDENTIFYING RELATIONSHIP
ATTRIBUTE
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
COMPOSITE ATTRIBUTE
DERIVED ATTRIBUTE
E1 R E2
TOTAL PARTICIPATION OF E2 IN R
1 N
E1 R E2
CARDINALITY RATIO 1:N FOR E1:E2 IN R
(min,max)
R E
STRUCTURAL CONSTRAINT (min, max) ON
PARTICIPATION OF E IN R
Entity
An entity is an object in the real world with an independent
existence (place, person, car, house, company, job, university, etc).
Graphically,
ENTITY Student
name
For example staff has 3 attributes
Name
Staff position
Position
Salary
salary
Entity Set
name
Employee Entity set
Domain of an Attribute
Graphically, Employee
name
phone
first_name
surname
Assign data to it
Derived Attributes
name age
Derived attribute
An exercise
stuNu stuName stuMajor stuDob stuHrs stuY stuGp stuAge
m r a
stuName
stuMajor
stuDob
stuHrs
stuYr
stuGpa
stuAge
Key Attributes
A key attribute minimal set of
attributes which uniquely identifies an
entity in the entity set. Underlined
salary name
e1
age id
e2
e3
e4
e5
Employee Entity set
e6
…
Primary Key
Employee
Candidate
eid nic
key
Composite Key
Sometimes, a group of attributes make
up the key. This is called a composite
key.
Example :
Composite key = (First name + surname + tel)
Key = NIC
Relationship
Relationship is an association among two or more entities.
Diamond
Collection of similar relationships - relationship set .
Shown as a line connecting the associated entities, labelled with
the name of the relationship.
N 1
Employee Works in Department
relationship
Descriptive Atributes
N 1
Employee Works in Department
1/2/97
111 1/2/99
D1
222
1/5/01
D2
333 1/2/87
D3
444
1/3/95
Departments
Employees
Work_in
Degree of Relationship type
Eg??
A Ternary Relationship
Location
Cardinality
The cardinality ratio for a binary relationship
specifies the number of relationship instances
that an entity can participate in.
one-to-one (1: 1)
one-to-many (1 : N)
many-to-many. (N : M)
One-to-One relationship
1 1
Employee Manages Department
Your Turn !!
N 1
Employee Works in Department
Participation Constraint
Student?
Your Turn !
Your Turn !!!
Determine
Cardinality
1 M
Employee Policy Departments
id name age
Example,
manages
supervisor subordinate
Employee
Your Turn !
Draw an ER diagram for the following
requirements.
(1,1)
(0,1)
1 1
(1,N)
(0,1)
N 1
Employee may or (NN
may not mange a department. He can at most
manage one department.
A department must be managed by an employee
Enhanced ER Modelling
salary
Staff
Specialization/generalization indicator
ISA
Manager & supervisor
Is of the type Staff
Manager Supervisor
bonus
mgrStartDate
Your Turn !
A university database contains information about
professors (identified by social security number, or SSN)
and courses (identified by course id). Professors teach
courses ;each of the following situations concerns the
Teaches relationship set. For each situation, draw an ER
diagram that describes it (assuming no further constraints
hold).