View
213
Download
0
Tags:
Embed Size (px)
Citation preview
DDBB
SSYYSSTTEEMMSS
Chapter 2Database System Design
(part II)
1
Based on G. Post, DBMS: Designing & Building Business Applications
University of ManitobaAsper School of Business
3500 DBMSBob Travica
Updated 2015
DDBB
SSYYSSTTEEMMSS
Special Associations: Aggregation
Sale
Item
* contains *SaleIDSaleDateEmployeeID
ItemIDDescriptionlistPrice
• Many-to-many relationship: Each sale transaction contains many items, and each item can be included in many sale transactions (provided items are keyed generically -ItemID identifies a sort of things). • Item and Sale are loosely coupled.
• SaleID is the unique key (identifies one specific sale transaction),
Sale1 ItemAItemB
Note: This is called instance diagramand it might help you with visualizing multiplicity.Sale2 ItemC
DDBB
SSYYSSTTEEMMSS
Special Associations: Composition(Part-Whole Relationship)
Association between the
whole class (Bicycle) and
part classes (Wheel,
Crank and Stem).
Two ways of displaying composition:
• The whole class is composed from part classes—it does not exist without certain parts.
• 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.
WheelWheelIDRimSpoke…
2
part of
Crank
CrankIDWeight
Stem
StemIDWeightSize
Bicycle
BicycleIDSizeModel Type…
1
1
A
Bicycle
SizeModel Type…
Wheel
Crank
Stem
B
• Typical use: Manufacturing, bill-of-materials
DDBB
SSYYSSTTEEMMSS
Generalization
AnimalAnimalIDDateBornNameGenderListPrice
MammalAnimalIDLiiterSizeTailLength
FishAnimalIDFreshWaterScaleCondition
SpiderAnimalIDVenomousHabitat
{disjoint}
is_a Is_a Is_a
• Superclass is parent class, and sub-class is the child class that inherits from parent.
Association between theSuperclass (Animal) and Sub-Classes (Mammal, Fish,Spider).
Example: Modeling dataon animals sold in a pet store.
• Generalization/Specialization resembles hierarchical classification schemes.• Multiplicity is assumed: 1:1
DDBB
SSYYSSTTEEMMSS
Inheritance
• Class Encapsulation of
– Data Attributes
– Methods (Behavior)
Account
AccountIDCustomerIDDateOpenedCurrentBalanceOpenAccountCloseAccount
Class name
Attributes
Methods
SavingsAccount
InterestRate
PayInterest
CheckingAccount
MinimumBalanceOverdraft
BillOverdraftFeesCloseAccount
Polymorphism
• Concept from Object Orientated Approach
Inheritance
• Properties:
– Parent class (Super-class) and Sub-classes – inheriting attributes & methods
– Unique attributes and methods in sub-classes (all listed)
– Polymorphism (variation of parent’s methods in children)
DDBB
SSYYSSTTEEMMSS
Class Diagram of Pet Store System
Animal
CustomerSupplier
Merchandise
AnimalPurchaseOrder
MerchandisePurchaseOrder
SaleEmployee
*
1
*
1
1
* *
1
1
**
1
**
*
*
* 1*1
SaleItemMerchOrderItem
Each animal keyeduniquely.
Merchandise keyedgenerically.
Note – differences from the textbook: Names of some classes modified. Association names not included. Some other slight modifications.
DDBB
SSYYSSTTEEMMSS
Data Types (Domains)
Format of data and range of values.
Access SQL Server Oracle Text fixed variable memo
Text Memo
char, nchar varchar, nvarchar text, ntext
CHAR VARCHAR2,NVARCHAR2 LONG
Number Byte (8 bits) Integer (16 bits) Long (32 bits) (64 bits) Fixed precision Float Double Currency Yes/No
Byte Integer Long NA NA Float Double Currency Yes/No
tinyint smallint int bigint decimal(p,s) real float money bit
INTEGER INTEGER INTEGER NUMBER(127,0) NUMBER(p,s) NUMBER, FLOAT NUMBER NUMBER(38,4) INTEGER
Date/Time Date/Time datetime smalldatetime
DATE
Image OLE Object image LONG RAW, BLOB AutoNumber AutoNumber Identity
rowguidcol SEQUENCES ROWID
Common Type
DDBB
SSYYSSTTEEMMSS
Computed Attributes
• Denote computed values. Written with a slash (/).
EmployeeNameDateOfBirth/AgePhone…
{Age = Today’s Date - DateOfBirth}
• Common example in business DB system: Sum=Item’s Sale Price * Quantity Sold
DDBB
SSYYSSTTEEMMSS
Events & Triggers+
Generate Standing Purchasing Order.
Scroll down slides file.
Change in time:
ON (LastDayInMonth)
Change in user interface:
OnClickOfMouse
Notify Purchasing Manager.
Change in data:
ON (QuantityOnHand < 100)
Decrease Inventory count.
Change in organization :
Item is sold.
Code (program) invoked by events.*
Definition:
Some change in organization, data, time, user interface invoking execution of certain code (programs).
TRIGGEREVENT
+ Discussion in the book somewhat confusing.
DDBB
SSYYSSTTEEMMSS
Rolling Thunder Bicycles: Package View
Sales Assembly
PurchasingLocation
Bicycle
Employee
• Package = A grouping of related elements to provide an overview of a database system.
• The way modern OO systems are designed and procured.
• Each package typically has more classes.
DDBB
SSYYSSTTEEMMSS
Rolling Thunder Bicycles: Sales Package
CustomerCustomerIDPhoneFirstNameLastNameAddressZipCodeCityIDBalanceDue
CustomerTransaction
CustomerIDTransactionDateEmployeeIDAmountDescriptionReference
Retail Store
StoreIDStoreNamePhoneContactFirstNameContactLastNameAddressZipCodeCityID
Bicycle::Bicycle
BicycleID… CustomerID
StoreID…
1..1
0..*1..1
0..*
0..*
0..1 From Bicycle package