Database Design

Victor Matos
1

Phases of Database Design
Data Requirements Specification of requirements and results Conceptual Design Conceptual Schema Logical Design Logical Schema Physical Design Physical Schema

 Conceptual

design begins 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 of the implementation (programs, tables, dictionaries, catalogs
2

Models
A data model is a collection of objects that can be used to represent a set of data and operations to manipulate the data  Conceptual models are tools for representing reality at a very high-level of abstraction  Logical models are data descriptions that can be processed by computers

3

Conceptual model: Entity-Relationship Diagrams
 Entities

represent classes of real-world

objects. Person, Students, Projects, Courses are entities of a University database  Relationships represent interactions between two or more entities
N 1

Lives_In Person Is_Born_In
N 1

City

4

Example:
 Every

employee works in at least one project  Every project has employees working on it.

EMPLOYEE SSN Name Salary

N

N WORKS_ON

PROJECT Name Code

5

Higher-Order Relationships
A relationship may involve more than two entities
Course Meets Classroom

Day
6

Recursive relationships
Relationships could be mapped from one entity to itself
Manager_Of 1

Employee N

Manages

Subordinate_To
7

Attributes
Attributes represent elementary properties of the
entities or relationships. The stored data will be kept as values of the attributes
Lives_In
N 1

PERSON Ssn Name Profession

Moving_Date Birth_Date

CITY Name Country Elevation Population
1

Is_Born_In
N

8

Generalizations
• An entity could be seen from many different viewpoints • Each viewpoint defines a set of roles in a generalization • Example below uses SEX to classify the object “Person”
PERSON Ssn Name Address

MAN Draft_Status

FEMALE Maiden_Name

9

Generalizations
A

classification could be disjoint or

overlapping
 An

entity could have more than one classification
PERSON Ssn Name Address

SEX

JOB

MAN Draft_Status

FEMALE Maiden_Name

Full_Time Annual_Salary Department

Part_Time Hour_Rate Weekly_Hours

10

Example: Department Store
A

1/2

department store operates in several cities  In a city there is one headquarter coordinating the local operations  A city may have several stores  Stores hold any amount of items  Customers place their orders for any number of items to a given store GOAL: Optimize shopping in each city

11

Example: Department Store
STORES Store ID Address Manager ID N 1 LOCATED IN CITIES City Name State HeadQtr Address

2/2

N N CUSTOMER Customer Name Address Phone Number

HOLD Qty Held

IN-CITIES Qty_in_cities

N

N 1

ITEMS Item ID Description Size Color

N

ITEMS ORDERED Qty Ordered

N

ORDERS Order Number Order Date

N PLACE

12

Example: University Database
 Professors

work for only one department  Departments have many professors  Each course is taught by only one professor  Students make a plan or program 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
13

University Database
CITY Name State N RESIDENT N N 1 N BIRTH_PLACE PERSON LastName Age DEPARTMENT Name Phone 1 Belongs_To

STUDENT

PROFESSOR TenureStatus Title

N

N 1 VISITING_ PROFESSOR Start_Appointment End_Appointment

ENROLLED Semester Grade

PLANNED Semester

GRADUATE_STUDENT

N

ADVISED_BY

N N COURSE Title Description Credits 1 TIME Day Hour N MEETS N ROOM RoomNumber Building N TAUGHT_BY Semester 1

University database

14

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

15

Soccer Database
PERSON Ssn Name Address

FAN Name Address Favorite Bar N SUPPORTS

PLAYER Uniform_Size Shoe_Size N PLAYS _FOR 1 TEAM Name Location Phone

COACH Personal Record Years Experience 1 MANAGES

N

1

N N PRACTICES

PLAY_ AGAINST

N

N

ATTENDS N N

GAME Number Attendance Final Score Date

N

TAKES PLACE AT

1

STADIUM Name Address Capacity

16

Research Project 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
17

Research Projects Database
RESEARCH REPORT Number Title 1 N ADDRESSES N N PRODUCES N RESEARCH PROJECT Name Code PRINCIPAL 1 INVESTIGATOR EMPLOYEE SSN Name Title SUPERVISE S N

RESEARCH TOPIC Code Name

N

ON

N

N

1

N FUNDED_BY Amount Date Grant# N AGENCY Name Address Contact Person

N

WORKS _ON

N

18

Contract-Supplies System
A

1/3

company negotiates contracts with suppliers to provide certain amount of items at a fixed price  Orders are placed against any of the already negotiated contracts  A contract could provide items to any number of orders

19

Contract-Supplies System
 An

2/3

order may include any number of items negotiated in the contract  Orders should not exceed the maximum amount of items quoted in the contract  All items in an order must be provided as part of a single contract and a single project

20

Contract-Supplies System
SUPPLIERS Supplier Number Name Address 1

3/3

NEGOTIATE Date of Contract

PROJECTS Project Number Project Data

N 1 CONTRACTS Contract Number Text 1 SUPPLIED AS NEEDED BY N

N TO SUPPLY Contract Price Contract Amount N ORDERS Order Number Date Required Date Completed N

ITEMS Item Number Description

N

MADE OF Order QTY

N

21

Manufacturing: Requisitions
 Projects

1/3

are broken into tasks  Tasks are assigned to departments  A task is created for one project and assigned to one department  Requisitions are made for projects  Each requisition could ask for any number of items
22

Manufacturing: Requisitions
 Each

2/3

requisition is for one project and is made to one supplier  Items could be: equipment or materials and are coded in a similar way  Suppliers send periodic price notices to advise the company of any changes in their prices

23

Manufacturing: Requisitions
PROJECTS Project Number Project Data 1 REQUESTS 1 MADE OF N TASKS Task Number Task Data 1 FOR N SUPPLIERS Supplier Number Supplier Data 1 SENDS

3/3

N REQUISITION Item Number Qty Requested N 1

FROM

N CONTAINS

N ITEMS Item Number Item Data 1 N

N PRICE ADVICE Price Effective Date

CHANGES

EQUIPMENT ITEM Code Description

MATERIAL ITEM Code Description Weight Container

24

Job-Shop Accounting System
 The

1/4

system is used by a company that manufactures special-purpose assemblies for customers  To manufacture assemblies the company creates a sequence of processes (steps)  Each process is supervised by a department  Assume there are three type of processes:

PAINT, FIT, CUT
25

Job-Shop Accounting System
 During

2/4

manufacturing an assembly could pass through any sequence of processes, in any order; it may pass through the same process more than once  A unique Job# is given to any new assembly.  Costs and started-terminated dates must be recorded
26

Job-Shop Accounting System
 An

3/4

accounting system is used to keep track expenditure for each:
DEPT,  PROCESS,  ASSEMBLY

 As

a job proceeds, cost transactions can be recorded against it.

27

Job-Shop Accounting System
CUSTOMER S Customer ID Address A1 ORDERS ASSEMBLY ACCOUNTS Account 1 Details DEPT ACCOUNTS Account 2 Details ACCOUNTS Account ID Date Established

4/4

T1 TRANSACTIONS T2

PROCESS ACCOUNTS Account 3 Details

ASSEMBLIE S Assembly ID Date Ordered Details ACTIVITY MADE AS

A2 T3 DEPARTMENT S Dept Number Dept Data

JOBS Job Number Starting Date Ending Date Total Cost CUT JOBS Cut Job ID Machine type used Material used Laor time PAINT JOBS Paint Job ID Color Volume Labor time

USED IN USES PROCESSES Process ID Process Data

A3

FIT JOBS Fit Job ID Labor time

PAINT PROC Paint Proc ID Paint Method

FIT PROC Fit Proc ID Fit Type

CUT PROC Cut Proc ID Cuttong Type Machine Type

28

Sign up to vote on this title
UsefulNot useful