CSE 6331 © Leonidas Fegaras OODB1 Object-Oriented Databases and the ODMG Standard.

Slides:



Advertisements
Similar presentations
Logical DB Design: ER to Relational Entity sets to tables. Employees ssn name lot CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER, PRIMARY.
Advertisements

Why Object-Oriented DBMS? Abstract data types Interface with host programming language (the impedance mismatch). Object identity: (peter, 40, {(john, 15,
Advanced Database: Seminar # 12: Object-Oriented Databases1 Object Oriented Databases Seminar 12 Exploring ODMG - OQL Using Lambda-DB.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Object Databases Baochuan Lu. outline Concepts for Object Databases Object Database Standards, Languages, and Design Object-Relational and Extended-Relational.
The Entity-Relationship Model
Databases CIS 422. Lifetime of Data Transient results to the evaluations of expression Variables involved in procedure activation Global variables Dynamically.
--The Object Database--1 The Object Database  Object databases integrate database technology with the object-oriented paradigm  In object databases,
ODMG Standard: Object Model1 OBJECT-ORIENTED DATABASE SYSTEMS ODMG Standard: Object Model Susan D. Urban and Suzanne W. Dietrich Department of Computer.
Object-Orientation in Query Languages By: Toan Nguyen Class: CS 157A.
Fall 2001Arthur Keller – CS 18015–1 Schedule Nov. 15 (TH) Object Queries (OQL). u Read Sections 9.1. Project Part 6 due on Sunday night. Nov. 20 (T) More.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Winter 2002Arthur Keller – CS 18016–1 Schedule Today: Mar. 5 (T) u More ODL, OQL. u Read Sections 9.1. Assignment 7 due. Mar. 7 (TH) u More OQL. u Read.
Programs with SQL Host language + Embedded SQL Preprocessor Host Language + function calls Host language compiler Host language program Preprocessor Host.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Object and Object- Relational Databases.
1 Announcements Research Paper due Monday November 22.
Databases Illuminated Chapter 7 The Object-Oriented Model.
Chapter 4 Object and Object-Relational Databases (Part ½: Object-Oriented Concepts) Lecturer: H.Ben Othmen Department of Computer Science, Umm Al-Qura.
Object-Oriented Database Design using UML and ODMG
EER vs. UML Terminology EER Diagram Entity Type Entity Attribute
Object and object-relational databases 1. Object databases vs. Object-relational databases Object databases Stores complex objects – Data + functions.
Database Design April 3, Projects, More Details Goal: build a DB application. (almost) anything goes. Groups of 3-4. End of week 2: groups formed.
Advanced Database CS-426 Week 2 – Logic Query Languages, Object Model.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Introduction to Objects & Databases These.
Object Query Language (OQL) and Language Binding
DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model.
Why Object-Oriented DBMS? Abstract data types (relational data model is too simple). Interface with host programming language Managing large number of.
Chapter 21 A Object Data Model - Intro Copyright © 2004 Pearson Education, Inc.
ADVANCED DATABASE SYSTEMS DR. FATEMEH AHMADI- ABKENARI SEPTEMBER Object Databases.
1 Advanced Databases – Lecture # 11 Object-Oriented Databases Advanced Databases Object Oriented Databases School of Informatics Akhtar Ali.
Database Management COP4540, SCS, FIU Database Modeling A Introduction to object definition language (ODL)
1 Chapter 1 Introduction. 2 Introduction n Definition A database management system (DBMS) is a general-purpose software system that facilitates the process.
Chapter 21 C OQL Copyright © 2004 Pearson Education, Inc.
Chapter 21 Object Database Standards, Languages, and Design Copyright © 2004 Pearson Education, Inc.
Object Definition Language
1 Advanced Databases (CM036) – Lecture # 12: The ODMG Standard for Object Databases Object Query Language (OQL) & Language Binding Advanced Database Technologies.
Object Definition Language
OOPSLA LAB. 1 Chapter 4 Object Query Languages Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University.
Database Design Why do we need it? – Agree on structure of the database before deciding on a particular implementation. Consider issues such as: –What.
Chapter 2: Intro to Relational Model. 2.2 Example of a Relation attributes (or columns) tuples (or rows)
11-1 CHAPTER 11 Concepts for Object-Oriented Databases.
COMP3030 Database Management System Final Review
© D. Wong Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:
Object-Relational Model. Review: Data Models Hierarchical Network ER (Pure) Relational (Pure) Object-oriented (ODMG) Object-relational (since SQL:1999)
AND OBJECT-ORIENTED DATABASES OBJECT-RELATIONAL DATABASES.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Object-Oriented Database.
1 CSE544 Monday April 26, Announcements Project Milestone –Due today Next paper: On the Unusual Effectiveness of Logic in Computer Science –Need.
The ODMG Standard for Object Databases
CSE 6331 © Leonidas Fegaras XQuery 1 XQuery Leonidas Fegaras.
Advanced Database: Seminar # 12: Object-Oriented Databases1 Object Oriented Databases Seminar 12 Exploring ODMG standard Using Lambda-DB.
1 Advanced Databases – Lecture # 12: The ODMG Standard for Object Databases Advanced Databases The ODMG Standard for Object Databases.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Chapter 12 Outline Overview of Object Database Concepts Object-Relational Features Object Database.
1 ODMG: ODL and OQL This lecture is a short version of: Lecture 11 (on ODL) & Lecture 12 (on OQL) M. Akhtar Ali School of Informatics.
Faeez, Franz & Syamim.   Database – collection of persistent data  Database Management System (DBMS) – software system that supports creation, population,
Chapter 21 Object Database Standards, Languages, and Design Copyright © 2004 Pearson Education, Inc.
Why Object-Oriented DBMS?
Object-Oriented Databases and the ODMG Standard
The Relational Model.
Database Design Why do we need it? Consider issues such as:
OBJECTS & DATABASES Arnaud Sahuguet – CIS-550.
Chapter 12 Outline Overview of Object Database Concepts
11. שפות ODL ו-OQL ותכנון מכוון עצמים
ISC321 Database Systems I Chapter 10: Object and Object-Relational Databases: Concepts, Models, Languages, and Standards Spring 2015 Dr. Abdullah Almutairi.
The Entity-Relationship Model
XQuery Leonidas Fegaras.
Chapter 15: Object-Oriented Database Development
1. Explain the following concepts of the ER data model:
CSC Database Management Systems
Object Database Standards, Languages, and Design
Presentation transcript:

CSE 6331 © Leonidas Fegaras OODB1 Object-Oriented Databases and the ODMG Standard

CSE 6331 © Leonidas Fegaras OODB2 Problems with Relational Databases Impedance mismatch between DML and application programming language: –different type systems –set processing vs. element-at-a-time processing –declarative vs. imperative programming paradigms. Normalization is a very bad idea: –an entity may be split over different tables –artificial keys are introduced when modeling nested sets Limited modeling power: –difficult to represent ordered sequences –difficult to represent hierarchical data (eg, XML data) –little support for multimedia types (BLOBs) –no data abstraction (ADTs) Limited processing power: –cannot return a nested result –group-by cannot be perform over complex expressions/functions

CSE 6331 © Leonidas Fegaras OODB3 OODBs Object identity identifies objects independent of value. Different from relational key. Methods model the behavior of an object. A class describes the state and the methods of every object that belongs to the class. Support for a complex type system, which includes atomic types (integer, real, string, etc), collection types (sets, bags, lists), records, etc. –types may be freely nested, which generalizes the nested relational model –classes define ADTs (new types and operations over these types) Support for class inheritance.

CSE 6331 © Leonidas Fegaras OODB4 The ODMG Standard It is an OODB standard that supports: an Object Description Language (ODL) for schema specification (using classes); an Object Query Language (OQL) for querying data, which resembles SQL; various host language bindings (C++, Java, Smalltalk, etc). ODL supports various type constructors. A type constructor constructs complex types from simple ones. They can be freely composed using: struct for building structures various collection types, such as set, bag, and list: set ; } >; } > The persistent root consists of the class extents (sets of class instances). In OQL you should refer to the extent, not to the class name. The class key uniquely identifies objects within the class.

CSE 6331 © Leonidas Fegaras OODB5 The University ODL Schema

CSE 6331 © Leonidas Fegaras OODB6 The University ODL Schema module School { struct Address { string city; short zipcode; }; class Person ( extent Persons key ssn ) { attribute long ssn; attribute string name; attribute Address address; }; …

CSE 6331 © Leonidas Fegaras OODB7 typedef set Degrees; class Instructor extends Person ( extent Instructors ) { attribute long salary; attribute string rank; attribute Degrees degrees; relationship Department dept inverse Department::instructors; relationship set teaches inverse Course::taught_by; long works_for (); short courses ( in string dept_name ); };

CSE 6331 © Leonidas Fegaras OODB8 class Department ( extent Departments keys dno, name ) { attribute long dno; attribute string name; attribute Instructor head; relationship set instructors inverse Instructor::dept; relationship set courses_offered inverse Course::offered_by; long avg_salary (); }; class Course ( extent Courses keys code, name ) { attribute string code; attribute string name; relationship Department offered_by inverse Department::courses_offered; relationship Instructor taught_by inverse Instructor::teaches; relationship set is_prerequisite_for inverse Course::has_prerequisites; relationship set has_prerequisites inverse Course::is_prerequisite_for; };

CSE 6331 © Leonidas Fegaras OODB9 OQL Path expressions: x.Aif x is an object or a struct and A is an attribute or a relationship name x.m(e1,…,en)if x is an object and m is a method For example, let e: Instructor, d: Department, c: Course Then these are legal paths: e.dept.name, d.head.name, d.instructors, c.taught_by.dept.name Illegal path expression: d.instructors.name(since d.instructors is a set )

CSE 6331 © Leonidas Fegaras OODB10 Struct and Object Construction struct ( a: 1, b: "a" ) struct ( x: struct( w: 1.7, a: “aa” ), y: 23 ) Department( name: “cse”, dno: 1289 ) Instructor( name: “Jones”, ssn: 2345, salary: 8000, dept: d, degrees: set(“MS”,“PhD”) )

CSE 6331 © Leonidas Fegaras OODB11 Constant Sets, Bags, and Lists set(1,2,1)(set of long) bag(“aaa”,“b”,“aaa”,“b”)(set of string) set(set(1,2),set(2,1))(set of set of long) element(set(3))  3 list(1,2)[1]  2 list(list(1,2),list(3,4))[1][0]  3 last(list(1,2,3))  3 first(list(1,2,3))  1 max(set(1,2,3))  3

CSE 6331 © Leonidas Fegaras OODB12 Select-from-where Remember: 1) entry points must be extent names 2) values in the FROM clause must be expressions that evaluate to collections. Rule: if a value is a collection, you use it in a FROM clause, otherwise, you use it in a path expression. select ssn, salary from Instructors where name = “Smith” select struct (issn: ssn, isalary: salary ) from Instructors where ssn>10 and ssn<12 select distinct e.dept.name from Instructors e where e.dept.head.name = “Smith”

CSE 6331 © Leonidas Fegaras OODB13 Dependent Joins select c.code from e in Instructors, c in e.teaches where e.name = “Smith” select c.name from c in Courses, d in c.is_prerequisite_for where d.name = “Advanced Databases” select ename: e.name, dname: e.dept.name from e in Instructors, s in e.dept.instructors, c in e.teaches where s.name = “Smith” and c.name = “DB II”

CSE 6331 © Leonidas Fegaras OODB14 Types are Very Important select ename: e.name, dname: e.dept.name from e in Instructors,(e is of type Instructor) s in e.dept.instructors,(s is of type Instructor) c in e.teaches(c is of type Course) where s.name = “Smith” and c.name = “DB II” Thus: s.name, c.name, and e.name are of type string e.dept is of type Department e.dept.name is of type string. The result type is: bag(struct(ename:string,dname:string))

CSE 6331 © Leonidas Fegaras OODB15 Alternative Forms Each relationship gives you two ways of accessing data: select c.code from e in Instructors, c in e.teaches where e.name = “Smith” select c.code from c in Courses where c.taught_by.name=“Smith” select c.name from c in Courses, d in c.is_prerequisite_for where d.name =“Advanced Databases” select c.name from d in Courses, c in d.has_prerequisites where d.name = “Advanced Databases”

CSE 6331 © Leonidas Fegaras OODB16 Other OQL Constructs The order-by clause constructs an ordered list and select-distinct constructs a set. Exists and for-all are used for existential and universal quantification: select e from e in Instructors where e.ssn > 10 and e.ssn < 15 order by e.name (select e from e in Instructors order by e.name)[10] for all x in Instructors: x.salary >= exists x in Instructors: x.salary >= exists e in Instructors: for all c in e.teaches: e.ssn > 10 and c.name = “DB II” element(select * from Instructors where ssn=60).teaches

CSE 6331 © Leonidas Fegaras OODB17 Nested Queries select e.ssn, e.salary from e in (select n from n in Instructors where n.name = “Smith”) select e.ssn from e in Instructors where exists c in e.teaches: c.offered_by.name = e.dept.name and e.name = “Smith” flatten(select teaches from Instructors where name = “Smith”) sum( select sum(select e.salary from e in d.instructors) from d in Departments )

CSE 6331 © Leonidas Fegaras OODB18 More Nested Queries select count(c.has_prerequisites) from c in Courses where c.name = “DB II” select x: e.name, y: (select c.name from c in e.teaches) from e in Instructors where e.ssn = 50 select x: e.name, y: (select x: c.name, y: count(c.has_prerequisites) from c in e.teaches) from e in Instructors where e.ssn = 50

CSE 6331 © Leonidas Fegaras OODB19 Group-By select distinct rank: er, avg_salary: avg(e.salary) from e in Instructors group by er: e.rank select distinct dno: dn, instr_num: count(e) from e in Instructors group by dn: e.dept.dno having dn > 6 select x, y, c: count(c) from e in Instructors, c in e.teaches group by x: e.ssn, y: c.name having x > 60 and y > “DB”

CSE 6331 © Leonidas Fegaras OODB20 More Group-By select distinct x, y, c: count(e) from e in Instructors group by x: count(e.teaches), y: (exists c in e.teaches: c.name=“DB II”) having x>0 Type of output: set(struct(x:long,y:boolean,c:long)) select distinct dno, low, high, c: count(d) from d in Departments group by dno: d.dno, low: count(d.courses_offered) <10, high: count(d.courses_offered) >=10

CSE 6331 © Leonidas Fegaras OODB21 The partition Variable More complex group-bys require the use of the partition variable: select degrees, prereqs, count(partition), max(select p.e.salary from p in partition) from e in Instructors, c in e.teaches group by degrees: count(e.degrees), prereqs: count(c.has_prerequisites) Partition is a set(struct(e: Instructor,c: Course)) and contains the (e,c) pairs for a single group.