Upload
shailja-singh
View
221
Download
0
Embed Size (px)
Citation preview
8/7/2019 03-ER-Diagrams(2) - Copy
1/28
1
Database Design
8/7/2019 03-ER-Diagrams(2) - Copy
2/28
2
Phases of Database Design
Conceptual designbegins with the
collection of requirements and results
needed from the database (ER Diag.)
Logical schema is a description of the
structure of the database (Relational,
Network, etc.)
Physical schema is a description ofthe implementation (programs, tables,
dictionaries, catalogs
Data
Requirements
Conceptual
Design
Logical
Design
Physical
Design
Conceptual Schema
Specification of requirements
and results
Logical Schema
Physical Schema
8/7/2019 03-ER-Diagrams(2) - Copy
3/28
3
Models
A data modelis a collection of objects that
can be used to represent a set ofdata and
operations to manipulate the dataConceptual models are tools for representing
reality at a veryhigh-level of abstraction
Logical models are data descriptions that canbe processed by computers
8/7/2019 03-ER-Diagrams(2) - Copy
4/28
4
Conceptual model:
Entity-Relationship Diagrams
Entities represent classes ofreal-world
objects. Person, Students, Projects, Courses
are entities of a University databaseRelationships represent interactions
between two or more entities
Pers
Is_B r _I
it
ives_I
N1
N 1
8/7/2019 03-ER-Diagrams(2) - Copy
5/28
5
Example:
Every employee works in at least one
project
Every project has employees working on it.
EMPLOYEE
SSNName
Salary
PROJECT
Name
Code
WORKS ONN
N
8/7/2019 03-ER-Diagrams(2) - Copy
6/28
6
Higher-Order Relationships
A relationship may involve more than two
entities
Course Meets Cl ssr oom
Day
8/7/2019 03-ER-Diagrams(2) - Copy
7/28
7
Recursive relationships
Relationships could be mapped from one
entity to itself
Manager_Of
Employee Manages
Subordinate_To
1
N
8/7/2019 03-ER-Diagrams(2) - Copy
8/28
8
Attributes
Attributes represent elementary properties of the
entities or relationships. The stored data will be
kept as values of the attributes
PERSON
Ssn
Name
Profession
Is orn In
CITY
NameCountry
Ele ation
Population
Li es InN 1
N 1
irth Date
Mo ing Date
8/7/2019 03-ER-Diagrams(2) - Copy
9/28
9
Generalizations
MAN
Draft Status
FEMALE
Maiden Name
PERSON
Ssn
Name
Address
An entity could beseen from many different viewpoints
Each viewpoint defines a set ofroles in a generalization
Example below uses SEXto classify the object Person
8/7/2019 03-ER-Diagrams(2) - Copy
10/28
10
Generalizations
A classification could be disjointor
overlapping
An entity could have more than oneclassification
MAN
Draft_ tatus
FEMALE
Mai en_ ame
PERSON
Ssn
Name
Address
SEX
Full_Tim
Annual_Salary
Department
Part_Tim
Hour_ ate
Weekly_Hours
OB
8/7/2019 03-ER-Diagrams(2) - Copy
11/28
11
Example: Department Store 1/2
A department store operates in several
cities
In a city there is one headquartercoordinating the local operations
A city mayhave several stores
Stores hold any amount of itemsCustomers place their orders for any
number of items to a given store
GOAL: Optimize shopping in each city
8/7/2019 03-ER-Diagrams(2) - Copy
12/28
12
Example: Department Store 2/2
CITIES
City Na e
State
HeadQtrAddress
STORES
Store ID
Address
Manager ID
LOCATED
IN
ITEMS
Item ID
Description
Size
Color
ORDERS
OrderNumber
OrderDate
ITEMSORDERED
Qty Ordered
HOLD
Qty Held
IN-CITIES
Qty_in_cities
CUSTOMER
CustomerName
Address
PhoneNumber
PLACE
N
N
1
N
N N
N N N
1
8/7/2019 03-ER-Diagrams(2) - Copy
13/28
13
Example: University Database
Professors work for only one department
Departments have many professors
Each course is taught by only one professor
Students make aplan orprogram of study
A course could meet in several rooms/times
Graduate students must have an advisor
Cities are categorized as resident/BirthPlace
Visiting prof. need an End/Start date
8/7/2019 03-ER-Diagrams(2) - Copy
14/28
14
University Database
University database
BIRT PLACE
CITY
NameState
PERSON
LastNameAge
PROFESSOR
TenureStatus
Title
STUDENT
DEPARTMENT
NamePhone Belongs To
ENROLLED
Semester
Grade
PLANNED
SemesterGRADUATE_STUDENT ADVISED BY
VISITING_
PROFESSOR
Start Appointment
End Appointment
COURSE
Title
Description
Credits
TAUG T BY
Semester
MEETS
ROOM
RoomNumber
Building
TIME
Day
our
RESIDENT
1 N
N
N
N
N
N
N
1
N N
N 1
1
N
N
1
8/7/2019 03-ER-Diagrams(2) - Copy
15/28
15
Soccer Database
A team has players, one coach, fans
Teams play according to a schedule
Teams need to practice in a Stadium
Attendance and scores must be recorded
8/7/2019 03-ER-Diagrams(2) - Copy
16/28
16
Soccer Database
FAN
Name
Address
Favori
e
ar
PLAYERUni
orm_Si e
Shoe_Sie
PERSON
Ssn
Name
Address
COACHPersonal Record
Years
xperience
SUPPORTSPLAYS
_FORMANAG
S
TEAM
Name
Location
Phone
PLAY_
AGAINST
GAME
Number
Attendance
Final ScoreDate
TAK
S
PLAC
AT
PRACTIC
S
STADIUM
Name
Address
Capacity
ATT NDS
N
N1
N 1
1
N N N 1
N
N
N N
8/7/2019 03-ER-Diagrams(2) - Copy
17/28
17
ResearchProject Database
Some employees are researchers
Every project has a leader investigator
Every project must be funded by an agency
A project may include several topics
A topic could appear in several projects
Researchers must produce report(s)
Each employee must have a supervisor
8/7/2019 03-ER-Diagrams(2) - Copy
18/28
18
ResearchProjects Database
RESEARCH TOPIC
Code
Name
RESEARCH REPORT
Number
Title
EMPLOYEE
SSN
Name
Title
ADDRESSES PRODUCES
PRINCIPAL
INVESTIGATORRESEARCH
PROJECT
NameCode
FUNDED
BY
Amount
Date
Grant#
AGENCY
Name
Address
Contact Person
WORKS
ON
N
N
N
N
N
N
SUPERVISE
S
N 11
1 N
N
ON
N
NN
8/7/2019 03-ER-Diagrams(2) - Copy
19/28
19
Contract-Supplies System 1/3
A company negotiates contracts with
suppliers to provide certain amount of items
at a fixed priceOrders are placed against any of the already
negotiated contracts
A contract could provide items to anynumber of orders
8/7/2019 03-ER-Diagrams(2) - Copy
20/28
20
Contract-Supplies System 2/3
An order may include any number of items
negotiated in the contract
Orders should not exceed the maximumamount of items quoted in the contract
All items in an order must be provided as
part of a single contract and a single project
8/7/2019 03-ER-Diagrams(2) - Copy
21/28
21
Contract-Supplies System 3/3
SUPP IERS
Supplier Nu ber
Na
e
Address
N
IA
Date of Contract
C
N
RAC
S
Contract Nu
ber
ext
I
ES
Ite
Nu
ber
Description
SUPPLY
Contract Price
Contract A
ount
AD
rder Q
Y
RDERS
rder Nu ber
Date Required
Date Co pleted
SUPPLI
D AS
N
D
D
Y
PR
JEC
S
Project Nu
ber
Project Data
1
N
1 N
N
N
N N
1
N
8/7/2019 03-ER-Diagrams(2) - Copy
22/28
22
Manufacturing: Requisitions 1/3
Projects are broken into tasks
Tasks are assigned to departments
A task is created for one project andassigned to one department
Requisitions are made for projects
Each requisition could ask for any numberof items
8/7/2019 03-ER-Diagrams(2) - Copy
23/28
23
Manufacturing: Requisitions 2/3
Each requisition is for one project and is
made to one supplier
Items could be: equipmentormaterials andare coded in a similar way
Suppliers send periodic price notices to
advise the company of any changes in theirprices
8/7/2019 03-ER-Diagrams(2) - Copy
24/28
24
Manufacturing: Requisitions 3/3
SUPPLIERS
Supplier
Number
SupplierData
PROJECTS
Project Number
Project Data
MADE OFTASKS
TaskNumber
TaskData
REQUESTS
REQUISITION
ItemNumber
QtyRequested
CONTAINS
ITEMS
ItemNumber
ItemData
EQUIPMENTITEM
Code
Description
MATERIALITEM
Code
Description
WeightContainer
CHANGESPRICEADVICE
Price
EffectiveDate
SENDS
FROM
FOR
REQUISITION
ItemNumber
QtyRequested
1 N
N
1
N
1
N 1
N
N
1 N
N
1
8/7/2019 03-ER-Diagrams(2) - Copy
25/28
25
Job-Shop Accounting System 1/4
The system is used by a company that
manufactures special-purpose assemblies
for customersTo manufacture assemblies the company
creates a sequence of processes (steps)
Each process is supervised by a departmentAssume there are three type of processes:
PAINT, FIT,CUT
8/7/2019 03-ER-Diagrams(2) - Copy
26/28
26
Job-Shop Accounting System 2/4
During manufacturing an assembly could
pass through any sequence of processes, in
any order; it may pass through the sameprocess more than once
A unique Job# is given to any new
assembly.
Costs and started-terminated dates must be
recorded
8/7/2019 03-ER-Diagrams(2) - Copy
27/28
27
Job-Shop Accounting System 3/4
An accounting system is used to keep track
expenditure for each: DEPT,
PROCESS,
ASSEMBLY
As a job proceeds, cost transactions can be
recorded against it.
8/7/2019 03-ER-Diagrams(2) - Copy
28/28
28
Job-Shop Accounting System 4/4CUSTOMER
S
Customer ID
Address
ORDERS
ASSEMBLIE
S
Assembly ID
Date Ordered
Details
CUT JOBS
Cut Job ID
Machine type
used
Material used
Laor time
JOBS
Job Number
Starting Date
Ending Date
Total Cost
FIT JOBS
Fit Job ID
Labor time
PAINT JOBS
Paint Job ID
Color
Volume
Labor time
A1
ACTIVITY
USES
MADE AS
TRANSACTIONS
PROCESS
ACCOUNTS
Account 3
Details
DEPT
ACCOUNTS
Account 2
Details
ASSEMBLY
ACCOUNTS
Account 1
Details
ACCOUNTS
Account ID
Date
Established
PROCESSES
Process ID
Process Data
DEPARTMENT
S
Dept Number
Dept Data
A2
T1
T3
T2
USED IN A3
CUT PROC
Cut Proc ID
Cuttong TypeMachine Type
FIT PROC
Fit Proc IDFit Type
PAINT PROC
Paint Proc IDPaint Method