Presentation is loading. Please wait.

Presentation is loading. Please wait.

By Shantanu Narang CS 157b. Relational Model  Object Model Object Oriented Databases(OOD) Object Query Language(OQL) OOD pros and cons.

Similar presentations


Presentation on theme: "By Shantanu Narang CS 157b. Relational Model  Object Model Object Oriented Databases(OOD) Object Query Language(OQL) OOD pros and cons."— Presentation transcript:

1 By Shantanu Narang CS 157b

2 Relational Model  Object Model Object Oriented Databases(OOD) Object Query Language(OQL) OOD pros and cons

3 Relation databaseJava Representation RelationClass TupleObject Composite Attributestruct Multi Valued AttributesCollection Objects Foreign KeyReference to an Objects

4 Relation databaseJava Representation One to OneStore worksAt = new Store(“BB”, UC); One to manyEmployee.worksOn = new Set (); Many to ManyAlmost all ORMs do not support many to many relationship. So most people have to hack there way around it. OR An easier way is to represent an the M-t-M as an entity class in the ERD. Preserve Referential Integrity(Important to update relationships)

5 // To make an employee a manager of a store /* *@param store is the store that the employee will manage *@return whether transaction was completed. */ protected boolean createManagerRelationsShip(Store store) { if(store.getManager() != null) return false; this.worksAt = store;// if different this.setManagerOf(store); store.setManager(this); return true; }

6 Single InheritanceClass Employee extends Person Multiple InheritanceNot allowed in java!! You have to create class variables, and manipulate them.(p. 442) Or Let interfaces simulate classes

7 Three ways to do it: 1.Write to file(text files, serialization in java) Impossible to load desired objects only. 2.Relational DBs. 3.Object DBs

8 The traditional Relational DBMS stores data in tables, rows, and columns Objects have several complex structures that cannot be represented in tables, rows, or columns. These structures include executable statements (i.e., methods) and pointers

9 An object database is a collection of persistent objects that act like a database. Object-relational mapping (aka ORM, O/RM, and O/R mapping) is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages. This creates, in effect, a "virtual object database" which can be used from within the programming language. Ex. Hibernate, LINQ, nHibernate.

10 OO vs. RM DBs

11 Based on SQL for an easier transition for programmers. Not as explicit as SQL, does not have command equivalent to the SQL-update. Example: Select distinct e.ssn from Employees e where e.lastname = “Booyaa” It will return a set object.

12 Select PayStatement(emp.id, emp.hours * emp.hourlySalary) from Employees emp where emp.isTemp() == true; #returns a set of new Paystatements object for all tempEmps

13 Supports Unions Intersections Except For all Exists Count Sum Nested statements Min Max Group by …………

14

15 The End


Download ppt "By Shantanu Narang CS 157b. Relational Model  Object Model Object Oriented Databases(OOD) Object Query Language(OQL) OOD pros and cons."

Similar presentations


Ads by Google