Object Query Language (OQL) and Language Binding

Slides:



Advertisements
Similar presentations
Advanced Database: Seminar # 12: Object-Oriented Databases1 Object Oriented Databases Seminar 12 Exploring ODMG - OQL Using Lambda-DB.
Advertisements

Object Databases Baochuan Lu. outline Concepts for Object Databases Object Database Standards, Languages, and Design Object-Relational and Extended-Relational.
1 Lecture 11: Basic SQL, Integrity constraints
INFS614, Fall 08 1 Relational Algebra Lecture 4. INFS614, Fall 08 2 Relational Query Languages v Query languages: Allow manipulation and retrieval of.
ODMG Standard: Object Model1 OBJECT-ORIENTED DATABASE SYSTEMS ODMG Standard: Object Model Susan D. Urban and Suzanne W. Dietrich Department of Computer.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Introduction to Structured Query Language (SQL)
Object-Orientation in Query Languages By: Toan Nguyen Class: CS 157A.
Introduction to Structured Query Language (SQL)
1 Pertemuan 17 Building Object Database Application Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
Programs with SQL Host language + Embedded SQL Preprocessor Host Language + function calls Host language compiler Host language program Preprocessor Host.
Introduction to Structured Query Language (SQL)
Chapter Implementation Faithful translation of a design into a target environment Design should be free of target-environment dependencies Should.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 7 Introduction to Structured Query Language (SQL)
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.
1 ODB Design Handling Associations in ODL M. Akhtar Ali School of Informatics.
Object-Oriented Database Design using UML and ODMG
1 ODB Design: Handling Associations and Inheritance in ODL M. Akhtar Ali School of Informatics.
Object and object-relational databases 1. Object databases vs. Object-relational databases Object databases Stores complex objects – Data + functions.
Advanced Database CS-426 Week 2 – Logic Query Languages, Object Model.
Agenda  TMA03  M877 Block 3 Databases with Objects.
DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XQuery.
CSE314 Database Systems More SQL: Complex Queries, Triggers, Views, and Schema Modification Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
ORDBS1 Object Relational Database Systems: 1. Introduction 2. Objects in SQL3 3. Comparison of ODL/OQL and SQL3 Approaches CIS 671.
Why Object-Oriented DBMS? Abstract data types (relational data model is too simple). Interface with host programming language Managing large number of.
1 Advanced Databases (CM036): Lecture # 5 ( Object-Relational and Nested-Relational Databases) Introduction to Object-Relational features of Oracle 9i.
8 October, 2001DBIS4 - RLC108 Object Query Language The need for ad hoc querying What SQL does What OQL must do OQL syntax and examples.
Object oriented databases
1 Advanced Databases – Lecture # 11 Object-Oriented Databases Advanced Databases Object Oriented Databases School of Informatics Akhtar Ali.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Chapter 21 C OQL Copyright © 2004 Pearson Education, Inc.
Chapter 21 Object Database Standards, Languages, and Design Copyright © 2004 Pearson Education, Inc.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
1 Advanced Databases (CM036) – Lecture # 12: The ODMG Standard for Object Databases Object Query Language (OQL) & Language Binding Advanced Database Technologies.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
OOPSLA LAB. 1 Chapter 4 Object Query Languages Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University.
1 CS457 Object-Oriented Databases Chapters as reference.
CSE 6331 © Leonidas Fegaras OODB1 Object-Oriented Databases and the ODMG Standard.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
1 CSCE Database Systems Anxiao (Andrew) Jiang The Database Language SQL.
Chapter 4 An Introduction to SQL. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.4-2 Topics in this Chapter SQL: History and Overview The.
© D. Wong Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:
My Research: Adding More Support for Relationships to DBMSs by Dr. Bryon K. Ehlmann Computer Science Department Southern Illinois University Edwardsville.
AND OBJECT-ORIENTED DATABASES OBJECT-RELATIONAL DATABASES.
The ODMG Standard for Object Databases
Component 4: Introduction to Information and Computer Science Unit 6: Databases and SQL Lecture 6 This material was developed by Oregon Health & Science.
OOPSLA Lab.1 Chapter 6 Smalltalk Binding Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University.
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.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
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.
Object-Oriented Databases (chapter 3/3) ODMG-OQL for querying the database Simple OQL Queries, Retrieving Objects – an example Database Entry Points Retrieving.
OOPSLA Lab1 Chapter 7 Java Binding Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University.
Object-Oriented Databases (chapter 2/3) Object Persistence - Introduction Persistent Programming Languages Specifying Object Persistence via Naming and.
Big Data Yuan Xue CS 292 Special topics on.
Chapter 4 An Introduction to SQL.
Object-Oriented Databases and the ODMG Standard
Advanced Databases Object Oriented Databases
Chapter 12 Outline Overview of Object Database Concepts
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
ODB Design: Handling Associations and Inheritance in ODL
Object Databases: Logical Data Modeling
Chapter 8 Advanced SQL.
Chapter 15: Object-Oriented Database Development
Information Retrieval and Web Design
Presentation transcript:

Object Query Language (OQL) and Language Binding The ODMG Standard for Object Databases Object Query Language (OQL) and Language Binding Advanced Database Technologies School of Computing, Engineering and Information Sciences Dr. Akhtar Ali

OQL – for querying the database OQL is the the query language in ODMG standard. OQL is a superset of the SQL (in select-from-where clauses). It can be interactive as well as embedded in other programming languages. It is a declarative language. OQL can invoke operations written in programming languages (C++, Java, Smalltalk). The operators in the language can be freely composed. OQL includes operators for creating collections, arithmetic and logical operators, aggregation, sorting and grouping.

Retrieving Objects or select l from l in Lecturers The query returns all Lecturer objects who live in Newcastle. The type of the query result is bag<Person>. Whenever the scope of an OQL query is a collection (e.g. Lecturers, a set of Lecturer objects), we define an iterator variable that ranges over the collection (e.g. l in Lecturer). In the query l denotes an object of type Lecturer. select l from l in Lecturers where l.address = “Newcastle” or from Lecturers as l from Lecturers l

Database Entry Points Named objects are entry points to the database (same as table or view names in RDBs). Class extents are usually used to refer to in OQL queries. Some frequently used objects can be assigned unique names e.g. CEIS a named Department object or AdvDB as named Unit object. To use named objects, you don’t have to write a query in select-from-where form. You can simply write: CEIS.staff which returns all staff member objects in the school of computing and mathematics. Students which returns a set of all Student objects in the database.

Retrieving data from multiple objects Without using Joins select struct(LName:l.name, DName:l.worksFor.name) from l in Lecturers The query contains an implicit join based on the relationship that exists between Lecturer and Department object types and due to the path expression l.worksFor.name. However, the user does not need to tell the OQL compiler. Using Joins select struct(LName:l.name, DName:d.name) from l in Lecturers, d in Departments where l.worksFor = d Here the user explicitly tells that a join should be performed on the basis of matching OIDs (l.worksFor and d denote an OID of a Department object).

Unnesting and Nesting Collections Unnesting a collection select struct(LName:l.name, SName:s.name) from l in Lecturers, s in l.tutees The query retrieves names of lecturers and their tutees in pairs. The query iterates over the collection Lecturers via the variable l; then iterates over l.tutees (a set of Student objects) via the variable s; then projects out name from l and name from s. The type of the query result is bag<LName:string, SName:string>. Nesting a collection select struct(LName:l.name, SNames:(select s.name from s in l.tutees) from l in Lecturers The query retrieves for every lecturer, his/her name and all his/her tutees names. Here instead of unnesting l.tutees, the query iterates over l.tutees via s and projects out name attribute and then constructs a collection out of it. The type of the query is bag<LName:string, SNames:bag<string>>.

Aggregate Functions A query to list module name, the number of lecturers teaching on the module and the number of students taking the module: select struct(Uname:u.name, Tno: count(u.taughtBy), Sno: count(u.takenBy)) from u in Units The query calls the count() aggregate function over the collections taughtBy and takenBy to return the required numbers. There is no need to do group by as the collections are integral parts of module objects. On a similar relational database, you would require to join several tables and use group by to answer a similar question in SQL, which may not be that efficient and easily expressed as the above OQL query.

Language Binding Extends an OOPL (C++, Java, Smalltalk) with ODL and OML (Object Manipulation Language) for building OODB applications. ODL binding defines how ODL constructs are mapped onto an OOPL. OML binding defines how objects are created, deleted, and modified in an OOPL. An OOPL may embed OQL where results returned by OQL queries can be manipulated by OOPL.

C++ ODL ODL C++ class Department (extent Departments) { attribute string name; relationship set<Lecturer> staff inverse Lecturer::worksFor; relationship set<Course)> offers inverse Course::offeredBy; }; ODL const char _worksFor[ ] = “worksFor”; const char _offeredBy[ ] = “offeredBy”; class Department : d_Object { public: d_String name; d_Rel_Set <Lecturer, _worksFor> staff; d_Rel_Set <Course, _offeredBy> offers; }; d_Extent<Department> Departments(DB1); // for extent // DB1 is the database name C++ for inverse relationships

C++ OML Object Creation Object Modification Object Deletion d_Ref<Student> S = new(DB1, “Student”) Student; // creates a new Student object in DB1 database d_Ref<Lecturer> L = new(DB1, “Lecturer”) Lecturer; // creates a new Lecturer object in DB1 database Object Modification S->name = “Richard Spring”; // modifies name attribute of Student S S->address = “Durham”; // similarly L->room = 103; // modifies room attribute of Lecturer L L->tutees.insert_element(&S); // establishes a relationship // between Lecturer L and Student S Object Deletion L.delete_object(); // deletes the Lecturer object from the database

C++ OQL Define variables for the query result d_Bag<d_Ref<Lecturer>> CEIS_Staff; d_Bag<d_Ref<Student>> ToonArmy; Create an instance of type d_OQL_Query d_OQL_Query q (“select l from l in Lecturers where l.worksFor.name = $1); d_OQL_Query q1 (“select s from s in Students where s.address = “Newcastle”); Modify the query with Parameters q << “CEIS”; // Imposes a restriction on the query Execute the query d_oql_execute(q, CEIS_Staff); // executes the query q and stores the result into CEIS_Staff variable d_oql_execute(q1, ToonArmy); // executes the query q1 and stores the result into ToonArmy variable

Summary An overview of ODMG standard An introduction to the Object Data Model A little bit of ODL Introduction to OQL Introduction to language binding