Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Design – Lecture 11 Introduction to Object Oriented Database Design.

Similar presentations


Presentation on theme: "Database Design – Lecture 11 Introduction to Object Oriented Database Design."— Presentation transcript:

1 Database Design – Lecture 11 Introduction to Object Oriented Database Design

2 2 Lecture Objectives Why Object Oriented Approach? Objects Classes Universal Modeling Language (UML)

3 3 Why Object Oriented Approach? Advances in application development drove the object oriented approach Applications are more complex - graphical user interfaces utilizing diverse data types such as sound, video and text Applications are based on ‘object’ patterns that have been developed and tested - reusability

4 4 Why Object Oriented Approach? Object Oriented Databases differ from Relational Databases but there are similarities: Relational model emphasizes an entity and it’s attributes and keeps separate the data manipulation Object Oriented model emphasizes attributes and data process – encapsulating both into a single object

5 5 Why Object Oriented Approach? Self-contained objects can be reused and moved around with relative ease Supports direct many-to-many relationships OO databases are navigational - Access to data is through relationships stored within the data themselves (remember hierarchical and network databases?) Not well suited to ad hoc queries

6 6 Why Object Oriented Approach? Two types of OO Databases Pure object-oriented - based solely on the object-oriented data model (I.e. CA – Jasmine) Hybrid object oriented – primarily relational – stores objects in relations (this is what we will focus on)

7 7 Lecture Objectives Why Object Oriented Approach? Objects Classes Universal Modeling Language (UML)

8 8 Objects “An object is an abstract representation of some real world entity that has a unique identity, embedded properties, and the ability to interact with other objects and act upon itself” (text) It is a software construct that encapsulates state and behavior

9 9 Objects Each of these objects has a unique identity but they share common general characteristics such as name, address, date of birth

10 10 Objects Objects are described by attributes or instance variables Each attribute has a unique name, a base data type (integer, string etc) and a domain (constraint) An object’s attribute can be single-valued or multi-valued An object can reference one or more other objects

11 11 Base data type is ‘real’ with values between 0.00 and 4.00 * Represents an attribute that references one or more other objects MAJOR references another object called DEPARTMENT ADVISOR references another object called PROFESSOR COURSES_TAKEN references another object called COURSE COURSE is a collection object because Course is a list of objects

12 12 Objects Each object has a unique identifier, called an OID (Object ID) **Note: this is not a primary key OID is assigned by the system at the moment the object is created and can never be changed OID does not depend on the object’s attribute values OID is deleted when the object is deleted and can never be re-used

13 13 Objects Note: There is no PK or FK notation in object oriented data design!

14 14 Objects State A set of values that the object’s attributes have at any given time To change the objects state, you must change the values of the object’s attributes To change the value of the object’s attributes, send a message to the object The message will invoke a method

15 15 Object Methods The code that performs a specific operation on the object’s data Can change the object’s attribute values or can return the value of selected object attributes An object invokes a method by sending a message Represents the object’s behavior

16 16 Lecture Objectives Why Object Oriented Approach? Objects Classes Universal Modeling Language (UML)

17 17 Classes A collection of similar objects with shared structure (attributes) and behavior (methods) All objects in a class share the same structure and the same methods Each instance of an object is a class instance or an object instance Each instance of a CLASS is an OBJECT with a unique OID

18 18 Classes Class is similar to an Entity in a relational data model Class contains the common features for all the objects in a class, including their structure and methods Class is a template to create the object

19 19 Classes Types of classes generally used: Entity – these classes reflect real world data which relates to the business requirements Boundary – these classes handle the communication between the system surrounding and the inside of the system (usually relate to interfaces) Control – these classes coordinate the events needed to realize the behavior (I.e. they know where to find the data but not how to find it)

20 20 Classes We will focus on the Entity class

21 21 Lecture Objectives Why Object Oriented Approach? Objects Classes Universal Modeling Language (UML)

22 22 UML Universal Modeling Language A methodology to follow to model Object Oriented structures We will use Rational Rose to document our OO structures Structure of a class in UML notation: Class Name Attributes Operations (Methods)

23 23 UML How are classes identified? Classes are identified for a use case A use case represents a process with a system Use case descriptions describe what a use case does. Scenarios describe different paths through a use case

24 24 UML Sample Use Case Diagram

25 25 UML Sample Use Case Description Use Case Specification: Browse Catalog Brief Description This use case describes how a shopper can browse the catalog of items that are available to be bid on. Preconditions At the moment when the use case begins, the system is displaying the Online Auction Main Page. Basic Flow 1.The use case begins when the shopper selects the Browse Catalog option on the Online Auction Main Page. 2.The system retrieves the list of categories (E1) and the system displays the Category Page with a drop down list of categories and an Exit Button. 3.If the shopper selects the Exit Button, the system performs Exit (S1). 4.If the shopper selects an option from the drop down list, the system retrieves all the items for that category (E1) and displays an Item List Page showing a table with item names with a Display Button and an Exit Button.

26 26 UML To discover classes: Use existing models (will identify classes, attributes and methods/operations) Use a category list (will identify classes, attributes) Use noun phrases (will identify classes, attributes) Objective is to find the data that is required We will identify entities as we did for relational – through a business overview and we will document the class diagram in Rational Rose

27 27 Existing Data Models Already published and can be re- used Retrieved from:

28 28 Category List Focuses on a list of common categories which emphasis business information system needs Conceptual Class CategoryExamples Business Transactions Guidelines: These are critical. Sale, Payment Transaction Line items Guidelines: These are the line items associated with transactions. SalesLineItem Product or service related to a transaction or a transaction line item Guidelines: Transactions are for something (a product or service) Item Roles of people or organizations related to the transaction; actors in the use case Guidelines: We usually need to know about the parties involved in a transactions Cashier, Customer

29 29 Noun Filtering Done for each scenario (not for a use case description) Underline the noun phrases in the scenario Place the candidate noun phrases into a noun filter table template Filter the noun phrases through a process of elimination Draw class diagram

30 30 UML Sample Scenario with noun filtering Scenarios HD Browse Item Scenario Precondition: At the moment when the scenario begins, the system is displaying the Online Auction Main Page. Actor System Selects the Browse Catalog option on the Online Auction Main Page. Retrieves the list of categories and displays the Category Page with a drop down list of categories and an Exit Button. Selects an option from the drop down listRetrieves all the items for that category and displays an Item List Page showing a table with item names with a Display Button and an Exit Button. Selects an item and clicks the Display Button.Retrieves the product name, it’s picture and a description and displays the information on the Item Information Page with a Place Bid Button and an Exit Button. Clicks the Place Bid Button.Use case ends and starts the Place Bid use case.

31 31 UML Sample Sequence Diagram – used to discover methods

32 32 UML Sample Class Diagram relationship Relationship name multiplicity classattributes methods/operations

33 33 UML Class Syntax Name – should meaningfully reflect the responsibility of the class I.e. Customer Attributes – the set of characteristics necessary to describe the class I.e. firstName, lastName, initial, dateOfBirth Each attribute has a unique name and data type Similar to attributes in relational (columns in a table) Operations/Methods – what actions can be carried out on an instance of the class I.e. addDateOfBirth, retrieveLastName

34 34 UML Attributes Can be of a base data type or an abstract data type Base data type i.e. real, integer, string or character Subject to a predefined set of operations (i.e. integer base data type can be used for addition, subtraction, multiplication and division) Can have a domain (constraint) Abstract data type User defined Describes a set of similar objects

35 35 UML Object Oriented Data Model A conceptual model Drawn in MSVisio 1. Identify the main entities 2. Identify attributes (both base data type and abstract data type). 3. If an abstract data type has attributes of its own, create a new class for that abstract data type and include the attributes in it

36 36 UML Sample class: Base data type abstract data types

37 37 Discovering Classes - Example Sun Life provides insurance plans to employees of Seneca. An employee must register for a plan. Each plan has a list of benefits associated with it (for instance, dental, orthodontic, prescriptions, glasses, long term disability etc). Employees can select which benefits they want (they don’t have to sign up for all of them). Employees can also cover their children (or dependents).

38 38 UML Sample Conceptual Class Diagram: Abstract data type Base data type

39 39 UML Sample Conceptual Class Diagram (with multiplicity):

40 40 Discovering Classes - Example Seneca College wants to create a website to allow an alumni or a company to be able to make contributions. These customers will be use an id to track their contributions. Contributions will include customer name, address and phone number. When a contribution is made, the customer can select a specific area for their contribution amount to be directed. For instance, they may want to direct their contribution to the athletic department, student housing or to a specific academic department such as Computer Studies. Customers need to specify whether they want a tax receipt or not and they can either be invoiced for their contribution or they can pay for it by credit card.

41 41 UML Sample Conceptual Class Diagram: Abstract data types – refer to another class

42 42 OO Database Design vs Relational Database Design Model PhaseOO ModelContentRelational Model Content Conceptual Model Object Oriented Data Model (OODM) – MSVisio Major classes; some attributes defined; shows all relationships (including M:N) Entity Relationship Diagram (ERD) – MSVisio Major entities; some attributes defined; shows all relationships (may show M:N) Logical ModelClass Diagram – Rational Rose Classes; attributes; relationships (can still have M:N) Entity Relationship Diagram (ERD) – MSVisio Entities; attributes; PKs, FKs, relationships (no M:N) Physical ModelRelational Schema – MSAccess Tables; attributes, PKs, FKs, all attributes atomic, no MVD


Download ppt "Database Design – Lecture 11 Introduction to Object Oriented Database Design."

Similar presentations


Ads by Google