Docsity

Representing Databases - Data Base Management System - Lecture Slides, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Representing Databases - Data Base Management System - Lecture Slides and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Representing databases with

Object Oriented -DB Models.

Preface

• Relational Model  Object Model

• Object Oriented Databases(OOD)

• Object Query Language(OQL)

• OOD pros and cons

Representing Relationships

Relation database Java Representation

One to One Store worksAt = new Store(“BB”, UC);

One to many Employee.worksOn = new Set();

Many to Many Almost 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)

Editing relationships in OOD

// 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;

Making objects persistence

Three ways to do it:

  1. Write to file(text files, serialization in java)

Impossible to load desired objects only.

  1. Relational DBs.
  2. Object DBs

Why not use a Traditional Relational

DBMS for your apps?

  • 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

OO vs. RM DBs

Object Query Language

  • 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.

OQL

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