You are on page 1of 12

D

University of Manitoba
B Asper School of Business
3500 DBMS
Bob Travica
S
Y Chapter 2
S Database System Design
(part II)
T
E Based on G. Post, DBMS: Designing & Building Business Applications
M Updated 2020

S
1
D Part-Whole Relationship: Aggregation
B
Sale Item
SaleID * contains * ItemID
SaleDate Description
S EmployeeID listPrice

Y • Many-to-many relationship:
S Each sale transaction contains many items, and each item can be
included in many sale transactions (provided items are keyed generically -

T ItemID identifies a sort of things).


• Item and Sale are loosely coupled.

E • SaleID is the unique key (identifies one specific sale transaction),

M Sale1 ItemA
ItemB
Note: This is called instance diagram
and it might help you with visualizing
Sale2 multiplicity.
S ItemC
D Part-Whole Relationship: Composition
B Two ways of displaying composition:
A B
Wheel Bicycle
Association between the WheelID
2
S whole class (Bicycle) and
part classes (Wheel,
Rim
Spoke
Size
Model Type
… …
Y Crank and Stem).
1
Crank
Wheel

S part of CrankID
Weight
Crank
T Bicycle
BicycleID
Stem
1
E Size
Model Type StemID
Weight
Stem

M Size

• The whole class is composed from part classes—it does not exist without certain parts.

S • Parts have purpose as the parts of a specific whole—they live and die with the whole.
• Therefore, part classes and whole class are tightly coupled.
• Typical use: Manufacturing, bill-of-materials
D Generalization
B
Association between the Animal Example: Modeling data
Superclass (Animal) and AnimalID on animals sold in a pet
Sub-Classes (Mammal, Fish, DateBorn store.
S Spider). Name
Gender
Y ListPrice
{disjoint}
S is_a Is_a Is_a

T Mammal Fish Spider


AnimalID AnimalID AnimalID
E LiiterSize
TailLength
FreshWater
ScaleCondition
Venomous
Habitat
M • Superclass is parent class, and sub-class is the child class that inherits from parent.

S • Generalization/Specialization resembles a hierarchical classification.


• Multiplicity is assumed: 1:1
D Inheritance
B • Concept from Object Orientated Approach
Class name Account
• Class Encapsulation of AccountID
CustomerID
– Data Attributes Attributes
S – Methods (Behavior)
DateOpened
CurrentBalance
Inheritance UpdateMonthly
Y • Properties:
Methods Balance

S – Parent class (Super-class) and


Sub-classes – inheriting
T attributes & methods SavingsAccount
InterestRate
CheckingAccount
MinimumBalance
– Unique attributes and methods
E in sub-classes (all listed)
Overdraft

– Polymorphism (variation of
M parent’s methods in children)
PayInterest BillOverdraftFees

S Polymorphism: Methods in Account may


work differently at children level.
D Class Diagram for Pet Store System
(Abbreviated): Unique & Generic Keys
B
Each animal keyed
uniquely. * *
Animal
1
S * Animal *
Y PurchaseOrder

1 1 1
S Supplier Employee
1 *
Sale
* 1
Customer

T 1 1 *
* *
E Merchandise
PurchaseOrder
MerchOrderItem
SaleItem

M *
*
*
Merchandise keyed
S generically.
Merchandise

Note – differences from the textbook: Names of some classes modified.


Association names not included. Some other slight modifications.
D Class Diagram for Pet Store System
(Abbreviated): Master & Transactional Classes
B Master class (M): M Transactional class (T):
-stable, sporadic changes * * -dynamic, frequent changes
-moderate amount of data Animal -large amount of data
lu de s
inc
S *
1
Animal * included in

Y PurchaseOrder

<
lls

ha
T
lfi

nd
fu

l
es
1 1 M
S M Supplier Employee
1 *
1
Sale * 1
M

Customer
handles made to
T 1
handles
1 T *
fulfills
E *
Merchandise
PurchaseOrder
*
MerchOrderItem
T
includes

SaleItem

M T incl *
ud e *
M * T
s
S Merchandise

• Note that master classes usually connect via transactional classes, not directly.
D Pet Store Schema (Normalized Tables Diagram)
B

S
Y
S
T
E
M
S Differences from class diagram:
-Associations not named
-Association classes became tables related to source classes
-Association between source classes disappeared
D Data Types ("Domains")
B
Format of data and range of values.
Data Type Access SQL Server Oracle

S Text
fixed
variable Text
char, nchar
varchar, nvarchar
CHAR
VARCHAR2,NVARCHAR2

Y memo
Number
Memo text, ntext LONG

Byte (8 bits) Byte tinyint INTEGER


S Integer (16 bits)
Long (32 bits)
Integer
Long
smallint
int
INTEGER
INTEGER
Precision (No. of digits)
Scale (No. of
decimal digits)

T
(64 bits) NA bigint NUMBER
Fixed precision dec. NA decimal(p,s) NUMBER(127, 0)
Floating Float real NUMBER, FLOAT [movable dec. point]

E Double floating Double


Currency
Binary choice
Currency
Yes/No
float
money
bit
NUMBER
NUMBER(38,4)
INTEGER
M Date, Time Date/Timedatetime
smalldatetime
DATE

Image OLE Object image LONG RAW, BLOB


S Auto integer AutoNumber Identity
rowguidcol
SEQUENCES
ROWID
D Computed Attributes
B
• Denote computed values. Written with a slash (/).

S Employee Calculated by its method, not stored:


Y Name
DateOfBirth
Age=Today’s Date-DateOfBirth
(the number of seconds

S /Age
Phone
from a historical start to date minus
the number of seconds from that start to
birth date)

T
E • Common example in business DB system:
M Sum=Item’s Sale Price * Quantity Sold

S
D Rolling Thunder Bicycles: Package View
B
Sales Bicycle Assembly
S
Y
S Employee

T
E Location Purchasing

M • Package = A grouping of related elements to provide

S an overview of a database system.


• Each package typically has more classes.
• The way modern OO systems are designed and procured.
D Rolling Thunder Bicycles: Sales Package
B
Customer 1..1 Bicycle::Bicycle
CustomerID BicycleID
Phone 1..1 …
S
0..*
FirstName CustomerID
LastName
Address 0..*
Y ZipCode
CityID
StoreID

S BalanceDue
Retail Store
From Bicycle package
T
0..1
Customer StoreID
Transaction StoreName

E CustomerID 0..* Phone


TransactionDate ContactFirstName
EmployeeID ContactLastName
M Amount
Description
Address
ZipCode

S Reference CityID

You might also like