Upload
harshgnitc3353
View
219
Download
0
Embed Size (px)
Citation preview
8/7/2019 ch2mod
1/18
Chapter 2
Database System Design
1
Based on G. Post, DBMS: Designing & Building Business Applications
University of Manitoba
Asper School of Business
3500 DBMSBob Travica
Updated 2010
8/7/2019 ch2mod
2/18
DD
BB
SS
YY
SS
TT
EEMM
SS
2 of 18
Development Activities
Specifications
for storage &
access methods
(indexes), and
forms & reports
Class diagram(classes &relationships)and writebusiness rules.
Business &
information
needs.
Pros & cons.
System
require-
ments.
Business
case.
Analysis
Create
data model.
Customer( CID, Name, )
SalesPerson(EID, Name..)
Order(OrderID, EID, CID,OrderDate..)
Adjust data model to
a database
technology
(e.g., relational).
Design
storage &
input/output.
List or diagram of
normalized tables
(schema).
Design ( Logical, Physical )Implement-
ation
8/7/2019 ch2mod
3/18
DD
BB
SS
YY
SS
TT
EEMM
SS
3 of 18
Unified Modeling Language (UML)
Trendy notation for analyzing systems and often used with theobject orientation (OO) approach.
Contains specific diagramming techniques:
The class diagram is most important for DB systems.
Similar to the old Entity-Relationship diagram (E-R diagram).
Class diagramA static model of classes and their relationships
Use case diagram Shows actors (users) and system functions.
Sequence diagram Interactions among objects with a timeline indicated.
Activity diagrams The steps within a function (or procedure, use case).
Implementation diagrams The structure of the code or of the run-time modules.
8/7/2019 ch2mod
4/18
DD
BB
SS
YY
SS
TT
EEMM
SS
4 of 18
Class Diagram Concepts
Entity: The thing in the real world tracked by the system.
Class: Description of an entity, that includes its attributes
(properties) and behavior (methods, procedures).
Object: One instance of a class with specific data; a record.
Attribute: A characteristic, an aspect, some quality that
describes a class or entity.
Behavior: Procedures (methods, processes, functions)
performed by the class.
Association: A relationship between classes.
8/7/2019 ch2mod
5/18
DD
BB
SS
YY
SS
TT
EEMM
SS
5 of 18
Entity: Customer
Class: Customer, includes attributes and behavior (below)
Object: 12257, Joe Jones... (a specific customer)
Attributes: CustID, Name...
Behavior: AddCustomer, DeleteCustomer...
Association: Customer is related to orders that he/she places.
Examples from Pet Store Application
8/7/2019 ch2mod
6/18
DD
BB
SS
YY
SS
TT
EEMM
SS
6 of 18
Associations
Associations (Relationships) represent business rules
Sometimes common-sense rules (Figure A)
NOTE: Assumed way of reading is left-right and top-down.
If the relationship is drawn that way, the arrowhead is not necessary.
Arrowheads help when these rules are not followed (Figure B).
placesf
(A) Customer Order
W belongs to
(B) CustomerProduct Search
Profile
Sometimes rules unique to an organization (Figure B)
8/7/2019 ch2mod
7/18
DD
BB
SS
YY
SS
TT
EEMM
SS
7 of 18
According to Number of classes:
Between 2 classes (previous slide; most used, most
important!) - binary
Between 3 or more classes N-ary
Class with itself (below) - unary
Degree of Association
Employee manager
worker
emanages
8/7/2019 ch2mod
8/18
DD
BB
SS
YY
SS
TT
EEMM
SS
8 of 18
Example:
An employee must work in only one department, and one (each)
department has one or more workers.
Multiplicity (Cardinality) of Associations
Specification of the number of objects participating in a relationship.
DepartmentEmployee
works in
1..11..*
Just maximum multiplicity is often used, and relationships are
named after it.
DepartmentEmployee
works in
1*
Example: many-to-one (M:1) relationship
8/7/2019 ch2mod
9/18
DD
BB
SS
YY
SS
TT
EEMM
SS
9 of 18
One-to-many (1:M)
- examples: CustomerOrder, ClientAccount
Many-to-many (M:N)
- examples: OrderItem, StudentCourse
One-to-one (1:1)
- example: CustomerBillingAddress
Types of Associations based onMultiplicity
8/7/2019 ch2mod
10/18
DD
BB
SS
YY
SS
TT
EEMM
SS
10 of 18
Procedure for Determining Multiplicity
(Form A)
And
1. Ask the multiplicity question:
One (each) object on the left side of the association is
associated with howmanyobjects on the right side?
Minimally, maximally?
DepartmentEmployee
works in
DepartmentEmployee
works in
1 ..1
2. Write the numbers/asterisks on the right side.
8/7/2019 ch2mod
11/18
8/7/2019 ch2mod
12/18
DD
BB
SS
YY
SS
TT
EE
MM
SS
12 of 18
1. Howmanyobjects on the left side are associated with
one (each) object on the right side?
2. Write the numbers/asterisks of the left side.
Procedure for Determining Multiplicity
(Form B)
Note: We usually specify just maximum multiplicity.
3. Howmanyobjects on the right side are associated with
one (each) object on the left side?
4. Write the numbers/asterisks on the right side.
DepartmentEmployee
works in f
1..11..*
8/7/2019 ch2mod
13/18
DD
BB
SS
YY
SS
TT
EE
MM
SS
13 of 18NOTE: Some imprecision on Fig. 2.7 on p. 39 (3rd
ed.); Fig 2.8 on p 46 (4th
ed.).
Notation for Multiplicity
Multiplicity options:
0 (zero)
1 (one)
* (many); in older notations M, N
specific number, if known (3, 10); e.g., in
part-whole relationship
Customer
Order
Item
1..1
1..*
0..*
1..*
.
places
containsOrder_Item
8/7/2019 ch2mod
14/18
DD
BB
SS
YY
SS
TT
EE
MM
SS
14 of 18
Business Rules for Cardinality - Read/Write
1) One customer can place one or
more orders,
and each order is placed by
one
and only one customer.
2) Each order can contain one or
more items,
and an item can be listed on no
order or on many orders.
Business Rules:
If min. multiplicity >= 1, association is mandatory;
If min. multiplicity = 0, association is optional.
Customer
Order
Item
1..1
1..*
0..*
1..*
.
places
contains
Order_Item
8/7/2019 ch2mod
15/18
DD
BB
SS
YY
SS
TT
EE
MM
SS
15 of 18
N-ary Association
Degree of association >= 3.
Components are built into Products by Employees.
Or, Products contain Components built in by Employees.
Support to inventory scheduling, quality control, performancemeasurement.
But, the data model is not complete as shown!
Employee
Component
Product
*
***
**
NOTE: Some imprecision on Fig. 2.8 on p. 40 (3rd
Ed.); Fig 2.9 on p. 46 (4th
ed.).
8/7/2019 ch2mod
16/18
DD
BB
SS
YY
SS
TT
EE
MM
SS
16 of 18
N-ary Association with Associative Class
N-ary associative class
Assembly introduced.
Each Assembly record lists
one employee, one
component, and one
product.
Employee
EmployeeIDName
Component
ComponetIDType
Name
Product
ProductIDName
EmployeeID Name
11 Joe Jones
12 Maria Rio
ProductID Name
A3222 Corvette
A5411 Camaro
E m plo ye eI D C om p Id P ro du ctI D
11 563 A3222
11 872 A3222
11 563 A5411
11 872 A541112 563 A3222
12 882 A3222
12 888 A3222
12 883 A5411
CompID Type Name
563 W32 Wheel
872 M15 Mirror
882 H32 Door hinge883 H33 Trunk hinge
888 T54 Trunk handle
Assembly
Assembly
EmployeeID
ProductIDCompID
8/7/2019 ch2mod
17/18
DD
BB
SS
YY
SS
TT
EE
MM
SS
17 of 18
N-ary Association
Component
ComponentIDType
Name
Product
ProductIDName
EmployeeID Name
11 Joe Jones
12 Maria Rio
EmployeeID ompI ro ctID
11 222
11 2 22211 11
11 2 11
12 222
12 2 222
12 222
12 11
ompID Type Name
W
2 Wheel
2 M1 Mirror
2 H
2 Door hinge H Tr nk hinge
T Tr nk han le
*
* *Assembly
Classes loose direct
relationships and get relatedvia the association class
Assembly, each creating a 1:M
relationship with Assembly.1
1 1
ro ctID Name
222 orvette
11 amaro
Employee
EmployeeID
Name
Assembly
EmployeeID
CompIDProductID
8/7/2019 ch2mod
18/18
DD
BB
SS
YY
SS
TT
EE
MM
SS
18 of 18
Focus on Keys: Generic vs. Unique
Product: specific model of car (ProductID is generickey
signifying a group ofthings)
Component: car door (ComponentID is a generickey)
Employee: assembly worker (EmoployeeID is a unique keysignifying a specificperson)
Note: The N-nary design in previous slides can be improved by
using unique keys (e.g., serial numbers) for products and
components. This would make it completely clear what worker
builds a specific component in a specific car (see Assembly
rows with values 11, 563, A3222 and 12, 563, A3222).