Presentation is loading. Please wait.

Presentation is loading. Please wait.

Burapha University, 2003 Object-Oriented Analysis Basic of Object Mapping to Relational Database.

Similar presentations


Presentation on theme: "Burapha University, 2003 Object-Oriented Analysis Basic of Object Mapping to Relational Database."— Presentation transcript:

1 Burapha University, 2003 Object-Oriented Analysis Basic of Object Mapping to Relational Database

2 Burapha University, 2003 Object-Oriented Analysis Mapping Classes to Tables Class map class to table Mapping Class to table map 1 Class to 1 Table map multiple Classes to 1 Table map multiple Classes to multiple Tables

3 Burapha University, 2003 Object-Oriented Analysis Mapping Attributes to Columns Class Attributes map class Attribute to column map Column to 0 column or more

4 Burapha University, 2003 Object-Oriented Analysis Mapping Classes to 1 Table

5 Burapha University, 2003 Object-Oriented Analysis Mapping Classes to 1 Table

6 Burapha University, 2003 Object-Oriented Analysis Mapping Classes to Tables

7 Burapha University, 2003 Object-Oriented Analysis Mapping Relationship Relationship and Foreign Key use Foreign Key to maintain relationship between 1 record in one table and another record in another table Relationship One-to-One One-to-Many and Many-to-One Many-to-Many

8 Burapha University, 2003 Object-Oriented Analysis Implementing One-to-One Relationship Position - title : String - salaryRange : double + toString( ) : String Employee - name : String - salary : double - startDate : Date + toString( ) : String + updateSalary( ) : String work at 1 1 Position positionID title Range Employee employeeID PositionID(FK) name salary startDate

9 Burapha University, 2003 Object-Oriented Analysis Implementing One-to-Many Relationship Employee - name : String - salary : double - startDate : Date + toString( ) : String + updateSalary( ) : String Job - description : String + toString( ) : String assigned to 1* Employee Job jobID description employeeID name salary startDate jobID(FK)

10 Burapha University, 2003 Object-Oriented Analysis Implementing Many-to-Many Relationship

11 Burapha University, 2003 Object-Oriented Analysis Mapping a class inheritance tree Startegies Vertical Mapping Horizontal Mapping Filtered Mapping

12 Burapha University, 2003 Object-Oriented Analysis One Table per Concrete Class (Horizonal Mapping) Person - personID : String - name : String - address : String - phoneNo : String Employee - employeeID : String - startDate : String - salary : double Customer - customerID : String - preference : String

13 Burapha University, 2003 Object-Oriented Analysis One Table per Class (Vertical Mapping) Person - personID : String - name : String - address : String - phoneNo : String Employee - employeeID : String - startDate : String - salary : double Customer - customerID : String - preference : String

14 Burapha University, 2003 Object-Oriented Analysis SELECT employee.ID, p.name, p.address, e.startDate, e.salary FROM Person p, Employee e WHERE e.personID=p.personID AND e.personID=100; instantiating an employee object with OID=100 requires a join of the Person and Employee tables:

15 Burapha University, 2003 Object-Oriented Analysis One Table per Hierarchy (Filtered) Person - personID : String - name : String - address : String - phoneNo : String Employee - employeeID : String - startDate : String - salary : double Customer - customerID : String - preference : String Person ID name address phoneNo Type startDate salary preferences objectType

16 Burapha University, 2003 Object-Oriented Analysis SELECT ID, name, address, phoneNo, startDate, salary FROM Person WHERE Type=1; The Type column is used as a filter used to distinguish the type of object being stored. For example, assuming that a Type=1 is used for employees, then to retrieve all employees from the Person table we can issue the following query: Person ID name address phoneNo Type startDate salary preferences objectType

17 Burapha University, 2003 Object-Oriented Analysis Comparing approaches to mapping Inheritance

18 Burapha University, 2003 Object-Oriented Analysis Summary Basic of mapping object to Relatoinal Database


Download ppt "Burapha University, 2003 Object-Oriented Analysis Basic of Object Mapping to Relational Database."

Similar presentations


Ads by Google