cs 4310: software engineering lecture 5 entity relationship modelling
TRANSCRIPT
![Page 1: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/1.jpg)
CS 4310: Software Engineering
Lecture 5
Entity Relationship Modelling
![Page 2: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/2.jpg)
2
Entity-Relationship Model
Technique for carrying out the conceptual and logical design of the system
A widely accepted data modelling approach
3 basic notions:
» entities» attributes» relationships
![Page 3: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/3.jpg)
3
What is an entity?
An entity is an object that can be identified in the users’ work environment and that users want to track.
![Page 4: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/4.jpg)
4
• An entity is a thing or object in the real world (within the application context)
• An entity has a set of properties which uniquely identify it.
• An entity is represented as a rectangle in an ER diagram
Entities
Project
![Page 5: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/5.jpg)
5
What is an Attribute?
An attribute describes a characteristic of an entity
For example:- An entity: Employee
- Has attributes:
» Employee_Name
» Extension
» Date_Of_Hire
![Page 6: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/6.jpg)
6
Example: Project = (proj_name, location, budget,
start_date, end_date)
Represented as ellipses in an ER diagram
Projectproj_name
locationbudget
start_date
end_date
Attributes
![Page 7: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/7.jpg)
7
What are Relationships?
Relationships are associations between entities which express some real world relationship
Project EmployeeEmploys
• Project and Employee participate in the employs relationship
• The function that an entity plays in a relationship is called that entity’s role
![Page 8: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/8.jpg)
8
Road Town
ends at
starts at• There can be more than
one relationship between entities.
• There can be recursive relationships that can indicate roles for clarity.
• A relationship can also have descriptive attributes.
Employee works for
Client Bookorders
date
manager
worker
Relationship Sets
![Page 9: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/9.jpg)
9
Degree of Relationships
Refers to the number of entities participating in a relationship
Most relationships are binary (degree 2), but can also have ternary (degree 3) relationships.
Project ContractorHires
Contract
number
value
start_date
end_date
Name
Address
proj_name
location
budget
start_dateend_date
![Page 10: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/10.jpg)
10
Express the number of entities to which another entity can be associated via a relationship
For a binary relationship, the mapping cardinality can be one of the following:
• one to one
• one to many
• many to one
• many to many
Mapping Cardinalities
![Page 11: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/11.jpg)
11
Cardinality Examples
A person has only one ID book and an ID book belongs to only 1 person
A person can own many cars (possibly 0), but a car only has 1 owner
A person can own many houses and a house can have multiple owners
Person ID Bookowns
Person Carowns
Person Houseowns
![Page 12: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/12.jpg)
12
Design Issues
Entity or Attribute?
• Example: should location be an entity or an attribute?
• can a project be in more than 1 location?
Entity or Relationship?
• generally: relationships for actions between entities
• whatever “makes sense” in application context
![Page 13: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/13.jpg)
13
ER Diagram Symbols
Entity Set
Attribute
Relationship
One-to-one link
Many-to-one link
Many-to-many link
![Page 14: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/14.jpg)
14
Example ERD
Project Employeeemploys
Alienspecies
area
start_date
first_name
position
proj_name
location
budgetstart_date
end_dateID surname
year_joined
year_leftend_date
eliminates
![Page 15: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/15.jpg)
15
ER Design: Where to Start
• Identify entity sets
• Describe the entity sets with attributes
• Specify relationships and cardinalities
![Page 16: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/16.jpg)
16
• Every department within the company is in only one division.
• Each division has more than one department in it.
• There is no upper limit on the number of departments that a division can have.
Simple Modelling Example
![Page 17: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/17.jpg)
17
Division
Department
Employee
1. Define Entities
![Page 18: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/18.jpg)
18
2. Define Relationships
Division
Department
Employee
contains
manages
![Page 19: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/19.jpg)
19
Division
Department
Employee
contains
manages
3. Define Cardinality
![Page 20: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/20.jpg)
20
Standard Notation
INVOICE
is sent by
A B
A B
A plain rectangle is used to represent the entity type.
A labeled line to represent the relationship.
1 : 1
1 : N
![Page 21: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/21.jpg)
21
Diagram with Standard Notation
Division
Department
Employee
contains
manages
![Page 22: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/22.jpg)
22
COURSE STUDENThas enrolled
LOAN BOOKrefers to
ONE loan refers to ONE book.ONE book is referred to ONE loan.
ONE course has enrolled ONE or MORE students.ONE student is enrolled on ONE course.
Notation Examples
![Page 23: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/23.jpg)
23
• Any one supplier might supply more than one kind of part.
• Any one kind of part might be bought from a number of different suppliers.
SUPPLIER PARTsupplies
Many-to-Many Relationship Example
![Page 24: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/24.jpg)
24
More Examples
Customer Order
Customer Property
Teachers Studentsteach
can place
is associated
![Page 25: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/25.jpg)
25
WARD
NURSE PATIENT
DOCTOR
treatsaccommodateshas
assigned
AILMENTsuffersfrom
caresfor
Example - Simple Hospital System
![Page 26: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/26.jpg)
26
DEPARTMENT
LECTURER
STUDENT
COURSE
is_in
enrols
teaches
offers
College System
![Page 27: CS 4310: Software Engineering Lecture 5 Entity Relationship Modelling](https://reader036.vdocuments.site/reader036/viewer/2022062422/56649edc5503460f94bed167/html5/thumbnails/27.jpg)
27
Your Project Work
• Develop Requirements Document.
• Think about your system’s entities and relationships