2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition
M i n i w o r l d R E Q U I R E M E N T S C O L L E C T I O N
A N D A N A L Y S I S D a t a b a s e
R e q u i r e m e n t s C O N C E P T U A L
D E S I G N C o n c e p t u a l
S c h e m a ( I n
a
h i g h - l e v e l
d a t a
m o d e l ) L O G I C A L
D E S I G N ( D A T A
M O D E L
M A P P I N G ) L o g i c a l
( C o n c e p t u a l )
S c h e m a ( I n
t h e
d a t a
m o d e l
o f
a
s p e c i f i c
D B M S ) P H Y S I C A L
D E S I G N I n t e r n a l
S c h e m a D B M S - i n d e p e n d e n t D B M S - s p e c i f i c F u n c t i o n a l
R e q u i r e m e n t s F U N C T I O N A L
A N A L Y S I S H i g h - l e v e l
T r a n s a c t i o n S p e c i f i c a t i o n A P P L I C A T I O N
P R O G R A M D E S I G N T R A N S A C T I O N I M P L E M E N T A T I O N A p p l i c a t i o n
P r o g r a m s Figure 3.1 A simplified diagram to illustrate the main phases of database design. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition Number Fname DEPENDENT Minit Lname Name Address Sex Salary Ssn ___ EMPLOYEE Bdate WORKS_FOR StartDate MANAGES NumberOfEmployees Name Locations DEPARTMENT CONTROLS PROJECT Name Location Number ______ WORKS_ON DEPENDENTS_OF N 1 Hours N Name Sex BirthDate Relationship N 1 1 N supervisor supervisee SUPERVISION 1 1 N 1 Figure 3.2 ER schema diagram for the company database. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition Headquarters = Houston Name = Sunco Oil President = John Smith c 1 Name = John Smith Address = 2311 Kirby, Houston, Texas 77001 Age = 55 HomePhone = 713-749-2630 e 1 Figure 3.3 Two entities, an employee e 1 and a company c 1 , and their attribute values. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition Address StreetAddress City State Zip Number Street ApartmentNumber Figure 3.4 A hierarchy of composite attributes; the StreetAddress component of an Address is further composed of Number, Street, and ApartmentNumber. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition {AddressPhone( {Phone(AreaCode,PhoneNumber)}, Address(StreetAddress(Number,Street,ApartmentNumber), City,State,Zip) ) } Figure 3.5 A complex attribute AddressPhone with multivalued and composite components. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition ENTITY TYPE NAME: ENTITY SET: (EXTENSION) COMPANY Name, Headquarters, President EMPLOYEE Name, Age, Salary (John Smith, 55, 80k) (Fred Brown, 40, 30K) (Judy Clark, 25, 20K) e 1 e 2 e 3 (Sunco Oil, Houston, John Smith) (Fast Computer, Dallas, Bob King) c 1 c 2 Figure 3.6 Two entity types named EMPLOYEE and COMPANY, and some of the member entities in the collection of entities (or entity set) of each type. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition CAR Registration(RegistrationNumber, State), VehicleID, Make, Model, Year, {Color} ((ABC 123, NEW YORK), WP9872, Nissan Maxima, 4-door, 1999, ((VSY 720, TEXAS), TD729, Chrysler LeBaron, 4-door, 1995, {white, blue}) ((ABC 123, TEXAS), TK629, Ford Mustang, convertible, 1998, {red, black}) car 1 car 2 car 3 {blue}) Figure 3.7 The CAR entity type, with two key attributes Registration and VehicleID. Multivalued attributes are shown between set braces {}. Components of a composite attribute are shown between parentheses (). Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition DEPARTMENT Name, Number, {Locations}, Manager, ManagerStartDate PROJECT Name, Number, Location, ControllingDepartment EMPLOYEE Name (FName, MInit, LName), SSN, Sex, Address, Salary, BirthDate, Department, Supervisor, {WorksOn (Project, Hours)} DEPENDENT Employee, DependentName, Sex, BirthDate, Relationship Figure 3.8 Preliminary design of entity types for the COMPANY database whose requirements are described in Section 3.2. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition e 1 r 1 r 2 r 3 r 4 r 5 r 6 r 7 d 1 d 2 d 3 EMPLOYEE WORKS_FOR DEPARTMENT e 2 e 3 e 4 e 5 e 6 e 7 Figure 3.9 Some instances of the WORKS_FOR relationship between EMPLOYEE and DEPARTMENT. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition SUPPLIER SUPPLY PROJECT s 1 s 2 r 3 r 4 r 5 r 6 r 7 j 3 j 2 j 1 p 2 p 1 p 3 PART r 2 r 1 Figure 3.10 Some relationship instances of a ternary relationship SUPPLY. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition 1 2 1 2 1 1 2 2 2 2 1 EMPLOYEE SUPERVISION e 1 e 2 e 3 e 4 e 5 e 6 e 7 r 1 r 2 r 3 r 4 r 5 r 6 Figure 3.11 The recursive relationship SUPERVISION, where the EMPLOYEE entity type plays the two roles of supervisor (1) and supervisee (2). Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition EMPLOYEE MANAGES DEPARTMENT e 1 e 2 e 3 e 4 e 5 e 6 e 7 r 1 r 2 r 3 d 1 d 2 d 3 Figure 3.12 The 1:1 relationship MANAGES, with partial participation of employee and total participation of DEPARTMENT. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition WORKS_ON EMPLOYEE PROJECT e 1 e 2 e 3 e 4 r 1 r 2 r 3 r 4 r 5 r 6 r 7 p 2 p 1 p 3 p 4 Figure 3.13 The M:N relationship WORKS_ON between EMPLOYEE and PROJECT. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition E E N T I T Y
T Y P E W E A K
E N T I T Y
T Y P E R E L A T I O N S H I P
T Y P E I D E N T I F Y I N G
R E L A T I O N S H I P
T Y P E A T T R I B U T E M U L T I V A L U E D
A T T R I B U T E S y m b o l M e a n i n g . . . K E Y
A T T R I B U T E C O M P O S I T E
A T T R I B U T E D E R I V E D
A T T R I B U T E E 1 E 1 E 2 E 2 E RRR 1 N ( M I N ,
M A X ) T O T A L
P A R T I C I P A T I O N
O F
E 2
I N
R C A R D I N A L I T Y
R A T I O
1 :
N
F O R
E 1 : E 2
I N
R S T R U C T U R A L
C O N S T R A I N T
( m i n ,
m a x ) O N
P A R T I C I P A T I O N
O F
E
I N
R Figure 3.14 Summary of ER diagram notation. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition supervisor (0,N) (1,1) controlled- project (1,1) Fname manager (0,1) StartDate employee SUPERVISION Bdate Salary Sex Name Address Lname Minit EMPLOYEE employee (0,N) (0,1) supervisee CONTROLS (0,N) controlling- department department- managed (1,1) MANAGES DEPARTMENT Locations (4,N) NumberOfEmployees department WORKS_FOR DEPENDENTS_OF Location project (1,N) WORKS_ON Hours worker (1,N) PROJECT dependent (1,1) Relationship BirthDate Sex DEPENDENT Ssn Name Number Name Name Number Figure 3.15 ER diagram for the COMPANY schema, with all role names included and with structural constraints on relationships specified using the alternate notation (min, max). Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition A i r p o r t C o d e N a m e C i t y S t a t e D E P A R T U R E A I R P O R T A R R I V A L A I R P O R T S c h e d u l e d
D e p T i m e S c h e d u l e d A r r T i m e L e g N o F L I G H T
L E G I N S T A N C E O F i n s t a n c e s W e e k d a y s N u m b e r A i r l i n e F L I G H T L E G S N1 F A R E S C o d eA m o u n t F A R E R e s t r i c t i o n s D a t e N o - o f - a v a i l s e a t s L E G I N S T A N C E C u s t o m e r N a m e C P h o n e R E S E R V A T I O N S e a t N o S E A T A S S I G N E D 1 N A I R P L A N E A i r p l a n e I d T Y P E T o t a l - n o - o f - s e a t s T y p e N a m e M a x - s e a t s C o m p a n y A I R P L A N E T Y P E D e p T i m e D E P A R T S A R R I V E S A r r T i m e C A N L A N D A I R P O R T MN N 1 N O T E S : ( 1 )
A
L E G
( S E G M E N T )
I S
A
N O N S T O P
P O R T I O N
O F
A
F L I G H T ( 2 )
A
L E G
I N S T A N C E
I S
A
P A R T I C U L A R
O C C U R R E N C E
O F
A
L E G
O N
A
P A R T I C U L A R
D A T E 1 N 1 N N N 1 1 1 N N 1 N Figure 3.16 An ER diagram for an airline database. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition BRANCHES BANK-BRANCH ACCTS Name Code Addr LOANS BANK LOAN ACCOUNT CUSTOMER A-C L-C BranchNo Balance Addr AcctNo Type Amount LoanNo Type SSN Name Addr Phone 1 N 1 N 1 N N N M M Figure 3.17 An ER diagram for a BANK database. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition EMPLOYEE DEPARTMENT HAS-PHONE CONTAINS PHONE WORKS-IN Figure 3.18 An ER diagram for a database that keeps track of company and employee phones. Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition INSTRUCTOR COURSE USES TEXT TEACHES Figure 3.19 An ER diagram for a database that keeps track of textbooks used in courses.