Introduction To Database Management System (CAS 372)
Introduction To Database Management System (CAS 372)
Lecture 5
High level conceptual data model Developed in 1976 (Chen) Describes DB structure and helps decide how retrieval & update transactions will work Design is independent of DB implementation Many DB support systems now allow automatic generation of applications and tables from E-R model
Entity-Relationship Terminology
ENTITY
Person, place, object, event, concept about which organisation needs to maintain data Can be physical (Person) or abstract (Project) Entity type (or class) is generic name Entity occurrence (or instance) is a single example of one entity type (project A/123)
ENTITY TYPES
Patient Medical History
Strong - exists independently of other types (e.g. Patient) Weak - depends on other type (e.g. patients medical history)
Property or characteristic of an entity (Patients telephone number) Can belong to more than one entity type (Doctors phone number) Similar things can be either entities or attributes in different organisations E-R models Sales organisation may have Product with attribute Colour Dyestuff manufacturer may have Entity Colour
DERIVED
Street
Simple Single-valued
PostCode
Composite Single-valued
Address
TelNo
Branch Simple Muli-valued
BranchNo
FaxNo TotalSalary
CARDINALITY (Number) Association between OPTIONALITY (Might or Must) one, two or more entities 1:1 Staff Branch Manages Conceptual model may include M:N Staff may (or not) manage only 1 branch relationships but Branch must have 1 (only 1) manager logical models usually limited to 1:1 or 1:N 1:M Staff Branch Employs Relationship has name describing Staff may be employed by 1 branch or no branches nature of Branch must have 1 and possibly have many employees relationship Relationships in Conceptual Model may have attributes, but not relationships in the Logical Model
N:M Newspaper
PlacesAdvert
Branch
Branch may place advert in 0, 1 or more newspapers Newspaper may carry adverts from 0, 1 or more branches
Branch
Recursive relationships involve same entity more than once, in different roles
Must identify relationship between weak (existencedependent) entities and associated strong entity
Staff may supervise 0, 1 or many other staff Each staff may be supervised by 0 or 1 other staff
Superclass entity has distinct subclasses that are represented separately Subclass inherits superclass attributes Subclass key will include superclass key Relationships may be between entities or subentities
Department
DeptNo DeptName
Employs
StaffNo Name Address Phone Subentity Salesperson: StaffNo Name Address Phone CarAllowance SalesArea
NOTATION PROBLEM
Employees may subsequently change departments and a history record is created for every department that the employee has worked for including the current one.
All employees except department heads are supervised by one other employee.
Each department should have a head of department although the position is currently vacant in at least one department.
Employees are encouraged to improve themselves by taking advantage of the training courses which the company offers. For maximum flexibility each course runs a number of times through the year and records are kept of which employees attend which courses, if any.
Course type
Department
Course
Employee
Employee history
Course type
Department
CoursesAlreadyRun
Manages
Currently employs
Supervises