Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Extensible Storage Engine wikipedia , lookup
Relational algebra wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
Clusterpoint wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Functional Database Model wikipedia , lookup
Versant Object Database wikipedia , lookup
Object Databases 1 A D VA N C E D D ATA B A S E S Y S T E M S D R . FAT E M E H A H M A D I - A B K E N A R I Limitations of Relational Data Model 2 Blob - Video - DNA Sequences - VLSI Chip designs Binary Large Object Examples MOVIE (Name: String, Director: String, Video: blob) 1 2 SELECT M. Director FROM MOVIE M WHERE M. Name = ‘ MMMMM’ Frames between 20000 and 50000 Burdening the database Huge Overhead ? Only with Specialized operation for a special Blob type e.g. frameRange (from, to) Limitations of Relational Data Model 3 Person IsA Hierarchies Student PERSON (Name: String, SSN: String) ER or UML extract STUDENT (SSN: String, Major: String) SELECT S. Name FROM STUDENT S WHERE S. Major = ‘CE’ Reject by SQL-92 No explicit presence of Name attribute SELECT P. Name FROM PERSON P, STUDENT S WHERE P.SSN=S.SSN AND S. Major = ‘CE’ More Complex No E-R or UML based query language Limitations of Relational Data Model 4 Impedance mismatch in database languages - Database applications are written in host languages such as C or Java Fact - 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). Problems Limitations of Relational Data Model 5 Set-valued attributes Relational data model is unable to handle setvalued attributes in natural way. An inevitable redundancy is a result. PERSON (SSN: String, Name: String, PhoneN: String, Child: String ) SSN Name PhoneN Child 111-22-3333 Joe Public 516-123-4567 222-33-4444 111-22-3333 Joe Public 516-345-6789 222-33-4444 111-22-3333 Joe Public 516-123-4567 333-44-5555 111-22-3333 Joe Public 516-345-6789 333-44-5555 222-33-4444 Bob Public 212-987-6543 444-55-6666 222-33-4444 Bob Public 212-987-1111 555-66-7777 222-33-4444 Bob Public 212-987-6543 555-66-7777 222-33-4444 Bob Public 212-987-1111 444-55-6666 If a person has several PhoneN and several Children Not in Third Normal Form SSN Name Conceptual Object Data Model (CODM) 6 Classes 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. Conceptual Object Data Model (CODM) 7 Terminology Extent of a Class Type of a Class Method Signature of a Class The set of all objects in a class The common structure of all objects in a class Declarations of operations that can be applied to the objects in a class Conceptual Object Data Model (CODM) 8 Objects and Values Arrays List Structures, … (# 32, [ SSN:111-22-3333, Name: Joe Public, Phone: {“516-123-4567”, “516-345-6789”}, Child: {#445, #73}] ) oid (Object ID) Complex Values 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} Objects in SQL 1999/2003 9 User-Defined Types (UDT) Abstract data type 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’; Objects in SQL 1999/2003 10 Using User-Defined Types CREATE TYPE TRANSCRIPT ( Student STUDENTTYPE, Creating Table CrsCode CHAR(6), Semester CHAR (6), CREATE TABLE TRANSCRIPT1 OF Grade CHAR(1) ) TRANSCRIPT Adding Objects INSERT INTO TRANSCRIPT1 (Student, Course, Semester, Grade) VALUES (NEW StudentType() .Id (987676767) . Status (‘H5’) . Name (‘John Smith’) . Address (ROW (456, ‘Florida Ave’, ‘5454545’)), ‘ADS’, ‘F911’ ‘A’) Objects in SQL 1999/2003 11 Reference Types 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’ Objects in SQL 1999/2003 12 Inheritance 1 2 CREATE TYPE STUDENTTYPE UNDER PERSONTYPE AS ( Id INTEGER, Status CHAR (2) ) A supertable for table STUDENT CREATE TABLE STUDENT OF STUDENTTYPE UNDER PERSON 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. Objects in SQL 1999/2003 13 Row Types ROW Type Constructor for construction of a tuple type 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 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 OQL: The ODMG Object Query Language 14 Methods in OQL MOVIE (Name: String, Director: String, Video: blob) SELECT M. frameRange (100, 1000) FROM MOVIE M WHERE M. Name = “Film1” Methods can be invoked in SELECT statement SELECT P. add_ phone_ number (“555-1212”) FROM PERSONEXT P This query changes the database but does WHERE P. SSN = “123-45-6789 ” 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.