Presentation is loading. Please wait.

Presentation is loading. Please wait.

ADVANCED DATABASE SYSTEMS DR. FATEMEH AHMADI- ABKENARI 1 Object Databases.

Similar presentations


Presentation on theme: "ADVANCED DATABASE SYSTEMS DR. FATEMEH AHMADI- ABKENARI 1 Object Databases."— Presentation transcript:

1 ADVANCED DATABASE SYSTEMS DR. FATEMEH AHMADI- ABKENARI 1 Object Databases

2 2 Limitations of Relational Data Model Blob Binary Large Object Examples MOVIE (Name: String, Director: String, Video: blob) SELECT M. Director FROM MOVIE M WHERE M. Name = ‘ MMMMM’ Huge Overhead 1 2 Frames between and ? Only with Specialized operation for a special Blob type e.g. frameRange (from, to) - Video - DNA Sequences - VLSI Chip designs Burdening the database

3 3 Limitations of Relational Data Model IsA Hierarchies Student Person ER or UML extract STUDENT (SSN: String, Major: String) SELECT S. Name FROM STUDENT S WHERE S. Major = ‘CE’ PERSON (Name: String, SSN: String) Reject by SQL-92 No explicit presence of Name attribute No E-R or UML based query language SELECT P. Name FROM PERSON P, STUDENT S WHERE P.SSN=S.SSN AND S. Major = ‘CE’ More Complex

4 4 Limitations of Relational Data Model Impedance mismatch in database languages -Database applications are written in host languages such as C or Java - Databases are accessed by executing SQL - SQL is a set oriented language and returns a set of tuples. - Host languages do not support high level operations on relations. - Host Languages are of procedural nature (how) while SQL is of declarative nature (what). Fact Problems

5 5 Set-valued attributes Limitations of Relational Data Model Relational data model is unable to handle set- valued attributes in natural way. An inevitable redundancy is a result. SSNNamePhoneNChild Joe Public Joe Public Joe Public Joe Public Bob Public Bob Public Bob Public Bob Public Not in Third Normal Form SSN Name If a person has several PhoneN and several Children PERSON (SSN: String, Name: String, PhoneN: String, Child: String )

6 6 Classes Conceptual Object Data Model (CODM) Similar Objects are organized into Classes Classes play the same role in CODM that Relations play in Relational Databases. In SQL-92 a Database is a set of Relations and each Relation is a set of Tuples. In CODM a Database is a set of Classes and each Class is a set of Objects. A Class has a Type, a Method Signature (a schema) and an Extent. The Method Implementation is not part of CODM. In Object Data Model, two classes can have the Sub/Super Class Relationship or IsA Relationship.

7 7 Terminology Conceptual Object Data Model (CODM) Extent Extent of a Class The set of all objects in a class Type Type of a Class The common structure of all objects in a class Method Signature Method Signature of a Class Declarations of operations that can be applied to the objects in a class

8 The Value part:  Primitive value (A member of Integer, String, Float, …)  Reference value (An oid of an object)  Tuple value: [A1:v1, …, A2:v2]  Set value: {v1, v2} 8 Conceptual Object Data Model (CODM) Objects and Values (# 32, [ SSN: , Name: Joe Public, Phone: {“ ”, “ ”}, Child: {#445, #73}] ) oid (Object ID) Complex Values Arrays List Structures, … In ODMG

9 9 User-Defined Types (UDT) Objects in SQL 1999/2003 CREATE TYPE PERSONTYPE AS ( Name CHAR (20), Address ROW (Number INTEGER, Street CHAR (20), ZIP CHAR (5) ) CREATE TYPE STUDENTTYPE UNDER PERSONTYPE AS ( Id INTEGER, Status CHAR (2) ) METHOD award_degree () RETURNS BOOLEAN; CREATE METHOD award_degree () FOR STUDENTTYPE LANGUAGE C EXTERNAL NAME ‘file:/…/…/award_degree’; Abstract data type

10 10 Using User-Defined Types Objects in SQL 1999/2003 CREATE TYPE TRANSCRIPT ( Student STUDENTTYPE, CrsCode CHAR(6), Semester CHAR (6), Grade CHAR(1) ) INSERT INTO TRANSCRIPT1 (Student, Course, Semester, Grade) VALUES (NEW StudentType(). Id ( ). Status (‘H5’). Name (‘John Smith’). Address (ROW (456, ‘Florida Ave’, ‘ ’)), ‘ADS’, ‘F911’ ‘A’) Adding Objects CREATE TABLE TRANSCRIPT1 OF TRANSCRIPT Creating Table

11 11 Reference Types Objects in SQL 1999/2003 CREATE TABLE TRANSCRIPT1 ( Student REF (STUDENTTYPE) SCOPE STUDENT2, CrsCode CHAR(6), Semester CHAR (6), Grade CHAR (1) ) Querying reference types SELECT T. Student -> Name, T. Grade FROM TRANSCRIPT T WHERE T. Student -> Address. Street = ‘ Shepard Ave’

12 12 Inheritance Objects in SQL 1999/2003 CREATE TYPE STUDENTTYPE UNDER PERSONTYPE AS ( Id INTEGER, Status CHAR (2) ) 1 2 CREATE TABLE STUDENT OF STUDENTTYPE UNDER PERSON A supertable for table STUDENT In order for a table T1 to be a subtable of another table T2 the following must hold:  The UDT of T1 must be a subtype of (defined as being UNDER) the UDT of T2.  The table T1 must be defined as being UNDER the table T2.

13 13 Row Types Objects in SQL 1999/2003 CREATE TABLE PERSON ( Name CHAR (20), Address ROW (Number INTEGER, Street CHAR (20), ZIP CHAR (5) ) SELECT P. Name FROM PERSON P WHERE P. Address. ZIP=‘11987’ Referring tuple types: Path Expression for SELECT ROW Type Constructor for construction of a tuple type ROW Value Constructor INSERT INTO PERSON (Name, Address) VALUES (‘John Doe’, ROW (666, ‘York Ville’, ‘55555’)) UPDATE PERSON SET Address = ROW (21, ‘Shepard Ave’, ‘12345’) WHERE Address = ROW (666, ‘York Ville’, ‘55555’) AND Name = ‘John Doe’ Updating tuple types

14 14 Methods in OQL OQL: The ODMG Object Query Language SELECT M. frameRange (100, 1000) FROM MOVIE M WHERE M. Name = “Film1” Methods can be invoked in SELECT statement MOVIE (Name: String, Director: String, Video: blob) SELECT P. add_ phone_ number (“ ”) FROM PERSONEXT P WHERE P. SSN = “ ” This query changes the database but does not return anything to the caller. The ability to call update methods in the OQL SELECT statement blurs the boundary between the data manipulation and query language.


Download ppt "ADVANCED DATABASE SYSTEMS DR. FATEMEH AHMADI- ABKENARI 1 Object Databases."

Similar presentations


Ads by Google