Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 2 Database System Design (part II)

Similar presentations


Presentation on theme: "Chapter 2 Database System Design (part II)"— Presentation transcript:

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

2 Part-Whole Relationship: Aggregation
Sale Item * contains * SaleID SaleDate EmployeeID ItemID Description listPrice 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), ItemA ItemB Note: This is called instance diagram and it might help you with visualizing multiplicity. Sale1 Sale2 ItemC

3 Part-Whole Relationship: Composition
Two ways of displaying composition: Wheel WheelID Rim Spoke 2 part of Crank CrankID Weight Stem StemID Size Bicycle BicycleID Model Type 1 A Bicycle Size Model Type Wheel Crank Stem B Association between the whole class (Bicycle) and part classes (Wheel, Crank and Stem). 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. Typical use: Manufacturing, bill-of-materials

4 Generalization Animal AnimalID DateBorn Name Gender ListPrice Mammal
LiiterSize TailLength Fish FreshWater ScaleCondition Spider Venomous Habitat {disjoint} is_a Is_a Association between the Superclass (Animal) and Sub-Classes (Mammal, Fish, Spider). Example: Modeling data on animals sold in a pet store. Superclass is parent class, and sub-class is the child class that inherits from parent. Generalization/Specialization resembles a hierarchical classification. Multiplicity is assumed: 1:1

5 Inheritance Concept from Object Orientated Approach
Account AccountID CustomerID DateOpened CurrentBalance UpdateMonthly Balance Class name Attributes Methods Class Encapsulation of Data Attributes Methods (Behavior) 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) SavingsAccount InterestRate PayInterest CheckingAccount MinimumBalance Overdraft BillOverdraftFees Polymorphism: Methods in Account may work differently at children level.

6 Class Diagram for Pet Store System (Abbreviated): Unique & Generic Keys
Each animal keyed uniquely. Animal Customer Supplier Merchandise PurchaseOrder Sale Employee * 1 SaleItem MerchOrderItem Merchandise keyed generically. Note – differences from the textbook: Names of some classes modified. Association names not included. Some other slight modifications.

7 Class Diagram for Pet Store System (Abbreviated): Master & Transactional Classes
Master class (M): stable, sporadic changes moderate amount of data M Transactional class (T): dynamic, frequent changes large amount of data * Animal * includes 1 * Animal PurchaseOrder * included in fulfills < handles T 1 1 M 1 M 1 * M Supplier * 1 Employee Sale Customer handles made to 1 1 T * handles fulfills * * includes Merchandise PurchaseOrder MerchOrderItem T SaleItem T * M T * * includes Merchandise Note that master classes usually connect via transactional classes, not directly.

8 Pet Store Schema (Normalized Tables Diagram)
Differences from class diagram: Associations not named Association classes became tables related to source classes Association between source classes disappeared

9 Data Types ("Domains") Format of data and range of values. Access
SQL Server Oracle Text fixed variable memo 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 dec. Floating Double floating Cur rency Binary choice Byte Integer Long NA Float Double Currency Yes/No tinyint smallint int bigint decimal(p,s) real float money bit INTEGER NUMBER NUMBER(127, 0) NUMBER, FLOAT [movable dec. point] NUMBER(38,4) Date, Time Date/Time datetime s malldatetime DATE Image OLE Object image LONG RAW, BLOB Auto integer AutoNumber Identity rowguidcol SEQUENCES ROWID Data Type Precision (No. of digits) Scale (No. of decimal digits)

10 Computed Attributes Denote computed values. Written with a slash (/).
Employee Name DateOfBirth /Age Phone Calculated by its method, not stored: Age=Today’s Date-DateOfBirth (the number of seconds from a historical start to date minus the number of seconds from that start to birth date) Common example in business DB system: Sum=Item’s Sale Price * Quantity Sold

11 Rolling Thunder Bicycles: Package View
Sales Assembly Purchasing Location Bicycle Employee Package = A grouping of related elements to provide an overview of a database system. Each package typically has more classes. The way modern OO systems are designed and procured.

12 Rolling Thunder Bicycles: Sales Package
Customer CustomerID Phone FirstName LastName Address ZipCode CityID BalanceDue Transaction TransactionDate EmployeeID Amount Description Reference Retail Store StoreID StoreName ContactFirstName ContactLastName Bicycle::Bicycle BicycleID 1..1 0..* 0..1 From Bicycle package


Download ppt "Chapter 2 Database System Design (part II)"

Similar presentations


Ads by Google