1 1 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM Catalogue versus Physical classes 2 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM A catalogue class is a class whose objects are reusable across multiple assemblies A physical class is a class whose objects are dedicated to at most one assembly Basic concepts A catalogue class is a class whose objects play a role of templates for the objects from the respective physical class A catalogue class is a description of a respective physical class 3 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM Example Buildings consist of rooms. A building is described by a number and height. A room is described by a number and area Physical class Room Consists-of Building b# ID height Room type 0..1 room# Catalogue class Room Are these designs equivalent ? Consists-of Building b# ID height Room type ID 0..1 1..* room# 2 4 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM b# room# type 17 1 lect 35 1 lab 35 2 lab Consists-of type lect lab tut Room b# height 17 200 35 150 Building b# room# type 17 1 lect 35 1 lab 35 2 lab Room b# height 17 200 35 150 Building Example Consists-of Building b# ID height Room type 0..1 room# Consists-of Building b# ID height Room type ID 0..1 1..* room# 5 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM Employees are described by employee number, first name and last name. Employees are hired on a given date and may leave at any time Physical class Hire Is-hired Employee e# ID fname lname Hire when-left[0..1] 0..1 when- hired Catalogue class Hire Is-hired Employee e# ID fname lname Hire when-hired ID 1..* 1..* EH when-left[0..1] Example 6 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM Physical classes Catalogue classes Book copy Book Room Room type Flight instance Flight Keyboard Keyboard blueprint Running course Course Assignment Assignment specs ??? ??? Sample physical and catalogue classes 3 7 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM Whiteboard example related to physical and catalogue classes 8 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM call# ISBN title price s# 100 I-567 Databases 250 6790 101 I-567 Databases 250 6791 Book s# name 6789 Janusz 6790 Marilyn 6791 Justina Student Borrows Book ISBN call# ID title price * Student s# ID name Incorrect choice of a class Students buy books. Students borrow books. Student s# ID name Buys Book ISBN ID title price * * 9 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM s# name 6789 Janusz 6790 Marilyn 6791 Justina Student call# ISBN s# 100 I-567 6790 101 I-567 6791 102 I-567 6791 103 I-777 6790 Book copy ISBN title price I-567 Databases 250 I-777 Java 200 Book Students borrow copies of books. Borrows Book copy call# ID * Student s# ID name Book ISBN ID title price * Is copy of Incorrect choice of a class 4 10 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM ISBN title price I-567 Databases 250 I-777 Java 200 Book s# name 6789 Janusz 6790 Marilyn 6791 Justina Student call# ISBN s# 100 I-567 6790 101 I-567 6791 102 I-567 6791 103 I-777 6790 Borrowing Borrowing call# ID Borrows * Student s# ID name Book ISBN ID title price * Students borrow books. Incorrect choice of a class 11 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM Students borrow books. A student can borrow the same book more than one time Repeatability of association call# ISBN s# 100 I-567 6790 101 I-567 6791 102 I-567 6791 103 I-777 6790 Borrowing 100 I-567 6790 Borrowing call# ID Borrows * Student s# ID name Book ISBN ID title price * A new row violates primary key constraint 12 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM Students borrow books. A student can borrow the same book more than one time call# bdate ISBN s# 100 12/04/10 I-567 6790 101 13/04/10 I-567 6791 102 15/05/10 I-567 6791 103 12/04/10 I-777 6790 Borrowing 100 15/06/10 I-567 6790 Repeatability of association Borrowing call# ID Borrows * Student s# ID name Book ISBN ID title price * bdate ID Generic identifier: (bdate, call#) Derived identifier: (s#, bdate, ISBN) 5 13 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM Whiteboard example related to repeatability of *-* associations 14 7. Catalogue versus Physical classes © Janusz R. Getta CSCI315 Database Design & Implementation (SIM, July 2016) 9/06/16 10:34 PM References Blaha M., Premerlani W., Object-Oriented modelling and Design for Database Applications, 1998, chapter 3 (BlahaPremerlani-3.pdf)