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

Slides:



Advertisements
Similar presentations
Advanced SQL (part 1) CS263 Lecture 7.
Advertisements

Why Object-Oriented DBMS? Abstract data types Interface with host programming language (the impedance mismatch). Object identity: (peter, 40, {(john, 15,
PHP and MySQL Database. Connecting to MySQL Note: you need to make sure that you have MySQL software properly installed on your computer before you attempt.
Object Databases Baochuan Lu. outline Concepts for Object Databases Object Database Standards, Languages, and Design Object-Relational and Extended-Relational.
ODMG Standard: Object Model1 OBJECT-ORIENTED DATABASE SYSTEMS ODMG Standard: Object Model Susan D. Urban and Suzanne W. Dietrich Department of Computer.
Employee database: Conceptual Schema in ERD Chapter 3, page 62.
Inclass Test Revision Database Technology Level I Lecture and Seminar Revision.
Programs with SQL Host language + Embedded SQL Preprocessor Host Language + function calls Host language compiler Host language program Preprocessor Host.
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.
1 ODB Design Handling Associations in ODL M. Akhtar Ali School of Informatics.
Object-Oriented Database Design using UML and ODMG
EER vs. UML Terminology EER Diagram Entity Type Entity Attribute
1 ODB Design: Handling Associations and Inheritance in ODL M. Akhtar Ali School of Informatics.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Seminar #3 CM036: Advanced Databases1 Seminar 4: Relational Algebra and its Simulation using SQL Purpose To understand how the relational operations are.
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.
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
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.
Seminar #: 9 (Object Oriented Database Schema in ODL) Advanced Databases (CM036) 1 Seminar 9 : OODB Schema in ODL Purpose To understand how an OODB is.
1 Advanced Databases (CM036): Lecture # 5 ( Object-Relational and Nested-Relational Databases) Introduction to Object-Relational features of Oracle 9i.
1 CS 430 Database Theory Winter 2005 Lecture 12: SQL DML - SELECT.
8 October, 2001DBIS4 - RLC108 Object Query Language The need for ad hoc querying What SQL does What OQL must do OQL syntax and examples.
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)
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.
OOPSLA LAB. 1 Chapter 4 Object Query Languages Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University.
Scaling Heterogeneous Databases and Design of DISCO Anthony Tomasic Louiqa Raschid Patrick Valduriez Presented by: Nazia Khatir Texas A&M University.
1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.
CSE 6331 © Leonidas Fegaras OODB1 Object-Oriented Databases and the ODMG Standard.
Seminar 10: OODB Design (Self-Study)
Seminar #: 10 (Object Oriented Database Design) Advanced DB Technologies (CG096) 1 Seminar 10 : OODB Design Purpose To understand how an OODB is structured.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 3 Data Modeling Using Entity-Relationship Model.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
The ODMG Standard for Object Databases
Seminar #: 10a (Object Oriented Database Design) Advanced Databases (CM036) 1 Seminar 10a : OODB Design Purpose This seminar is the continuation of seminar.
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.
1 ODB Design Handling Inheritance in ODL M. Akhtar Ali School of Informatics.
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.
Relational Algebra COMP3211 Advanced Databases Nicholas Gibbins
Object-Oriented Databases (chapter 2/3) Object Persistence - Introduction Persistent Programming Languages Specifying Object Persistence via Naming and.
Why Object-Oriented DBMS?
Object-Oriented Databases and the ODMG Standard
COMP3017 Advanced Databases
Advanced Databases Object Oriented Databases
Seminar 10 : OODB Design (Self-Study)
Seminar 6 : OODB Schema in ODL
SQL: Advanced Options, Updates and Views Lecturer: Dr Pavle Mogin
SQL: Structured Query Language DML- Queries Lecturer: Dr Pavle Mogin
Chapter 12 Outline Overview of Object Database Concepts
Seminar 9: OODB Design (Self Study)
CPSC-310 Database Systems
20761B 12: Using Set Operators Module 12   Using Set Operators.
Web DB Programming: PHP
ODB Design: Handling Associations and Inheritance in ODL
Chapter 8 Advanced SQL.
Using Script Files and Managing Data
Chapter 15: Object-Oriented Database Development
SQLPLUS: Oracle SQL Interface
Presentation transcript:

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

Advanced Database: Seminar # 12: Object-Oriented Databases2 Example Schema in ODL module University { interface Person { attribute string name; attribute string address; attribute date birthDate; }; class Lecturer : Person (extent Lecturers) { attribute short room; relationship set tutees inverse Student::tutor; relationship Department worksFor inverse Department::staff; relationship set teaches inverse Unit::taughtBy; }; class Student : Person (extent Students) { attribute string major; relationship Lecturer tutor inverse Lecturer::tutees; relationship Course enrolledOninverse Course::hasStudents; relationship set takesinverse Unit::takenBy;}; class Department (extent Departments) { attribute string name; relationship set staffinverse Lecturer::worksFor; relationship set offers inverse Course::offeredBy; }; class Course (extent Courses) { attribute string name; relationship Department offeredByinverse Department::offers; relationship set hasStudentsinverse Student::enrolledOn; relationship set hasUnitsinverse Unit::partOf; }; class Unit (extent Units) { attribute string name; attribute string code; relationship set takenBy inverse Student::takes; relationship set taughtByinverse Lecturer::teaches; relationship set partOfinverse Course::hasUnits; }; };

Advanced Database: Seminar # 12: Object-Oriented Databases3 Object Creation – the Database // Department instances %d1 := Department(name:"Computing"); %d2 := Department(name:"Maths"); %d3 := Department(name:"Engineering"); // Lecturer instances %Date_Type doBirth; doBirth.year = 1965; doBirth.month = 12; doBirth.day = 25; %i1 := Lecturer(name:"Neil Eliot", address: "South Shields", birthDate: doBirth, worksFor: d1); %i2 := Lecturer(name:"Julia Robert", address: "Durham", worksFor: d2); %i3 := Lecturer(name:"David Meyer", address: "Sunderland", worksFor:d1); %i4 := Lecturer(name:"Alex Shearer", address: "Newcastle", worksFor:d3); %i5 := Lecturer(name:"Norman Paton", address: "Northumberland", worksFor: d3); %i6 := Lecturer(name:"David Livingston", address: "Northumberland", worksFor: d1); %i7 := Lecturer(name:"M Akhtar Ali", address: "Newcastle", worksFor:d1); %i8 := Lecturer(name:"Patric Patterson", address: "Newcastle", worksFor: d2); // Course instances %c1 := Course(name:"Bsc Computing for Business", offeredBy: d1); %c2 := Course(name:"MSc Computing Conversion", offeredBy: d1); %c3 := Course(name:"Bsc Mathematics", offeredBy: d1); %c4 := Course(name:"Bsc Electrical Engineering", offeredBy: d1); // Student objects %s1 := Student(name:"Jane Smith", address: "Durham", major : "Computing", tutor: i1, enrolledOn: c1); %s2 := Student(name:"Mark Brown", address: "Newcastle", major : "Computing", tutor: i3, enrolledOn: c2); %s3 := Student(name:"Andrew Tailor", address: "Fenham", major :"Maths", tutor: i2, enrolledOn: c3); %s4 := Student(name:"Samanta Fox", address: "Gosforth", major : "Maths", tutor: i1, enrolledOn: c2); %s5 := Student(name:"Sandra Falcon", address: "Jesmond", major :"Engineering", tutor: i5, enrolledOn: c4); %s6 := Student(name:"Pedro Sampaio", address: "Morpeth", major :"Engineering", tutor: i3, enrolledOn: c1); %s7 := Student(name:"Sarah Khan", address: "Durham", major : "Computing", tutor: i1, enrolledOn: c1); %s8 := Student(name:"Ian Prat", address: "Newcastle", major :"Computing", tutor: i3, enrolledOn: c2); %s9 := Student(name:"Andrew Shah", address: "Fenham", major : "Maths",tutor: i2, enrolledOn: c3); %s10 := Student(name:"Alex Fernandes", address: "Gosforth", major :"Maths", tutor: i1, enrolledOn: c2); %s11 := Student(name:"Hena Kattak", address: "Jesmond", major :"Engineering", tutor: i5, enrolledOn: c4); %s12 := Student(name:"Maria Willian", address: "Morpeth", major :"Engineering", tutor: i3, enrolledOn: c1); // Unit objects %u1 := Unit(name: "Advanced Databases", code: "CM036"); %u2 := Unit(name: "OO Modelling", code: "CM031"); %u3 := Unit(name: "Elementrary Algebra", code: "MATH065"); %u4 := Unit(name: "Descret Mathematics", code: "MATH045"); %u5 := Unit(name: "Tranformers", code: "EE038"); %u6 := Unit(name: "Electronic Beams", code: "EE073");

Advanced Database: Seminar # 12: Object-Oriented Databases4 Object Creation – continued… // link Unit objects with Course objects c1->update()->hasUnits.add(u1); c2->update()->hasUnits.add(u1); c1->update()->hasUnits.add(u2); c2->update()->hasUnits.add(u2); c3->update()->hasUnits.add(u3); c1->update()->hasUnits.add(u4); c3->update()->hasUnits.add(u4); c4->update()->hasUnits.add(u5); c4->update()->hasUnits.add(u6); // link with students u1->update()->takenBy.add(s1); u1->update()->takenBy.add(s2); u1->update()->takenBy.add(s7); u2->update()->takenBy.add(s8); u2->update()->takenBy.add(s1); u2->update()->takenBy.add(s2); u2->update()->takenBy.add(s7); u3->update()->takenBy.add(s3); u3->update()->takenBy.add(s4); u3->update()->takenBy.add(s1); u3->update()->takenBy.add(s10); u3->update()->takenBy.add(s11); u3->update()->takenBy.add(s9); u4->update()->takenBy.add(s2); u4->update()->takenBy.add(s4); u4->update()->takenBy.add(s1); u4->update()->takenBy.add(s10); u4->update()->takenBy.add(s7); u4->update()->takenBy.add(s9); u5->update()->takenBy.add(s5); u5->update()->takenBy.add(s6); u5->update()->takenBy.add(s11); u5->update()->takenBy.add(s12); u6->update()->takenBy.add(s5); u6->update()->takenBy.add(s11); u6->update()->takenBy.add(s12);

Advanced Database: Seminar # 12: Object-Oriented Databases5 Querying using OQL Simple Query Named objects – entry points Path expressions Explicit Joins select l.name from l in Lecturers The query returns names of lecturers such that the type of the result is bag. Departments The query returns all Department objects. The type of the query is set. select struct(Lname:l.name, Dname:l.worksFor.name) from l in Lecturers The query returns names of lecturers and their departments. Note that this in this query, l.worksFor.name is path expression. The query returns names of lecturers and their department by joining them (but the query does not include any join condition). The type of the result is bag. This query has an implicit join. select struct(Lname:l.name, Dname:d.name) from l in Lecturers, d in Departments where l.worksFor = d and d.name = "Computing" 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). The type of the result is bag.

Advanced Database: Seminar # 12: Object-Oriented Databases6 OQL Queries – continued … Unnesting Query – to unnest a collection A Nesting Query – to create nested collection select struct(Dname:d.name, AccStaff: (select l.name from l in d.staff)) from d in Departments The query returns names of departments and their employees. The inner query iterates over the collection staff and projects out lecturer name and creates a collection, and in the outer query the result of the inner query is assigned to the variable AccStaff. The type of the query is bag >. 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, which unnests this collection; then projects out name from l and name from s. The type of the query result is bag. select struct(LName:l.name, SName:s.name) from l in Lecturers, s in l.tutees

Advanced Database: Seminar # 12: Object-Oriented Databases7 OQL Queries – continued … Aggregation select distinct struct(Lname:l.name, Dname:l.worksFor.name, TuteesNo: count(l.tutees) from l in Lecturers where count(l.tutees) >= max(select count(t.tutees) from t in Lecturers) This query retrieves the names of lecturers and their departments such that the lecturers have maximum tutees. The type of the query is set. The query can be written more efficiently in two steps as: maxNo := max(select count(t.tutees) from t in Lecturers) select distinct struct(Lname:l.name, Dname:l.worksFor.name, TuteesNo: count(l.tutees) from l in Lecturers where count(l.tutees) >= maxNo The query retrieves names of units and the number of teaching staff and the students who take these units. The type of the query result is bag. select struct(Uname:u.name, Tno: count(u.taughtBy), Sno: count(u.takenBy)) from u in Units

Advanced Database: Seminar # 12: Object-Oriented Databases8 Using Lambda-DB Open a DOS/command window. Connect to cgapp2 using your Unix user account and password by writing telnet cgapp2 on DOS prompt. From now on every thing you type is case-sensitive. Run the script for setting up seminar12 files by /home/makhtarali/setupOQLdemo Go to the folder university by cd /data/cm036/YourUserName/university Replace YourUserName by your unix login name. Run make build to create your own workspace if you have not done so in week 10 or 11. Run make to compile the schema in university.odl and the program populate.oql for constructing objects. Run./populate to populate the database. Run make query to compile the queries in query.oql file. Run./query >query.out to execute the queries and write its output to query.out file. Run more query.out to view the results. Just before you logout, run the following commands: cd ~/ rm –rf /data/cm036/YourUserName