OBJECT-DATABASE SYSTEM Object-Oriented database system


Published on

  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • OBJECT-DATABASE SYSTEM Object-Oriented database system

    1. 1. OBJECT-DATABASE SYSTEM <ul><li>Object-Oriented database system </li></ul><ul><ul><li>are proposed as an alternative to relational system and aimed at application domains where complex objects play a central role. </li></ul></ul><ul><li>Object-relational database systems </li></ul><ul><ul><li>can be thought of as an attempt to extend relational database system with the functionality necessary to support a broader class of application... </li></ul></ul>
    2. 2. Object-database Systems <ul><li>RDBMS </li></ul><ul><ul><li>Relational Database Management Systems </li></ul></ul><ul><li>OODBMS </li></ul><ul><ul><li>Object-Oriented Database Management Systems </li></ul></ul><ul><li>ORDBMS </li></ul><ul><ul><li>Object-Relational Database Management Systems </li></ul></ul><ul><li>ODBMS </li></ul><ul><ul><li>Object-Database Management Systems </li></ul></ul>
    3. 3. Object-database vendor <ul><li>IBM (db2) </li></ul><ul><li>Oracle </li></ul><ul><li>Informix </li></ul><ul><li>Sybase </li></ul><ul><li>Microsoft SQL </li></ul>
    4. 4. New Data Types <ul><li>User-define abstract data type (ADT) </li></ul><ul><ul><li>Dinky’s assets include Herbert’s image, voice, and video footage, and these must be stored in the database - Must write compress functions to support (lower resolution). </li></ul></ul><ul><li>Structured types </li></ul><ul><ul><li>In this application, as needed in many traditional business data processing applications, we need new types built up from atomic types using constructors for for creating sets, records, arrays, sequences, and so on.. (see section 25.5) </li></ul></ul>
    5. 5. New Data Type <ul><li>Inheritance </li></ul><ul><ul><li>As the number data types grows, it is important to recognize the commonality between different types and to take advantage of it. </li></ul></ul><ul><li>BLOB (A binary large object) </li></ul><ul><ul><li>is just a long stream of bytes, and DBSM’s support consists of storing and retrieving BLOBs in such manner - </li></ul></ul><ul><ul><li>Users don’t worry the size of the BLOB </li></ul></ul><ul><ul><li>BLOB can span several pages </li></ul></ul><ul><ul><li>Unlike a traditional attributes </li></ul></ul><ul><ul><li>Can be done in the host language in which the SQL code is embedded. </li></ul></ul>
    6. 6. Large objects in SQL <ul><li>SQL:1999 </li></ul><ul><ul><li>includes a new data type called LOB </li></ul></ul><ul><ul><ul><li>BLOB (binary large object_ </li></ul></ul></ul><ul><ul><ul><li>CLOB (character relational object) </li></ul></ul></ul><ul><ul><li>LOBs cannot be included in primary keys, </li></ul></ul><ul><ul><ul><li>GROUP BY </li></ul></ul></ul><ul><ul><ul><li>ORDER BY </li></ul></ul></ul><ul><ul><li>A LOB has a locator </li></ul></ul><ul><ul><ul><li>that is a unique id and allows to be manipulated without extensive copying. </li></ul></ul></ul><ul><ul><li>LOBs are stored separately from data records in whose fields they appear. </li></ul></ul><ul><ul><li>Supports LOB: DB2,Infomix,MS SQL,Oracle8,Sybase ASE. </li></ul></ul>
    7. 7. 25.1.2 Manipulating the new Kind of Data <ul><li>SELECT F.frameno, thumnail(F.image),C.lease_price </li></ul><ul><li>FROM Frames F, Categories C </li></ul><ul><li>WHERE F.categories = C.cid AND is_sunrise(F.image) AND is_herbert(F.image) </li></ul><ul><li>(Figure 25.1) DDL statement on page 740. </li></ul><ul><li>SELECT N.theater->name, N.theater->address, F.title </li></ul><ul><li>FROM Nowshowing N, Films F, Countries C </li></ul><ul><li>WHERE N.film = F.filmno AND overlaps(C.boundary,radius(N.theater->address ,100)) AND C.name = ‘Andora’ AND ‘Herbert the worm’ element F.stars </li></ul><ul><li>(Figure 25.3 on page 741). </li></ul>
    8. 8. Manipulating the New kind of Data <ul><li>User-define Methods </li></ul><ul><ul><li>User-defined abstract types are manipulated via their methods, for example, is_herbert (25.2) </li></ul></ul><ul><li>Operators for structured types </li></ul><ul><ul><li>setof (section 25.3.1) </li></ul></ul><ul><li>Operator for reference types </li></ul><ul><ul><li>are dereferenced via an arrow (->) notation (section 25.4.2) </li></ul></ul>
    9. 9. User-Defined Abstract Data types <ul><li>JPEG standard </li></ul><ul><ul><li>Jpeg_image </li></ul></ul><ul><ul><li>polygon (a column boundary of type) </li></ul></ul><ul><li>ORDBMS key feature is allowing users to define arbitrary new data type. Such as: </li></ul><ul><ul><ul><li>compress, rotate, shrink and crop </li></ul></ul></ul><ul><li>Combination of an atomic data type and its associated methods is called: Abstract data type (ADT). Such object-relational systems, user allows to include ADT. </li></ul>
    10. 10. 25.2.1 Defining Methods of n ADT <ul><li>Size </li></ul><ul><li>Import </li></ul><ul><li>Export </li></ul>
    11. 11. 25.3 Structure Types <ul><li>ROW </li></ul><ul><ul><li>A type representing a row, or record, of n field with fields n of type n….etc </li></ul></ul><ul><li>Listof(base) </li></ul><ul><ul><li>Type representing a sequence of base-type items </li></ul></ul><ul><li>Array(base) </li></ul><ul><ul><li>A type representing an array of base-type items </li></ul></ul><ul><li>Setof(base) </li></ul><ul><ul><li>A type representing a set of base-type items. Sets cannot contain duplicate elements. </li></ul></ul><ul><li>bagof(base) </li></ul><ul><ul><li>A type resenting a bag or multiset of based-type items. </li></ul></ul>
    12. 12. Structure types <ul><li>Structure data types in SQL:1999 </li></ul><ul><ul><li>Row type </li></ul></ul><ul><ul><li>Array </li></ul></ul><ul><ul><li>Row and Array </li></ul></ul><ul><li>The listof,bagof and setof type constructors are not included in SQL:1999, IBM DB2, Informix, UDS, and Oracle 8 support the Row constructor. </li></ul>
    13. 13. 25.3.1 Manipulating Data of Structure Types <ul><li>Built-in Operators for Structure types </li></ul><ul><li>Rows </li></ul><ul><ul><li>ROW(n1 t1,…,) Dot notation, i.n of k. </li></ul></ul><ul><li>Sets and multisets </li></ul><ul><ul><li>Set of objects can be compared using the traditional set methods. </li></ul></ul><ul><ul><li>An item of type setof(foo) can be comapred with an item of type foo using the Element method. </li></ul></ul><ul><ul><li>Lists </li></ul></ul><ul><ul><li>Traditional list operations include head, which return the first element. </li></ul></ul>
    14. 14. 25.3.1 Manipulating Data of Structure Types <ul><li>Arrays </li></ul><ul><ul><li>Array types support an ‘array index’ method to allow users to access array items at a particular offset. </li></ul></ul><ul><li>Others operators – Count,Sum,Avg,Max & Min. </li></ul><ul><li>SELECT F.filmno </li></ul><ul><li>FROM Films F </li></ul><ul><li>WHERE count(F.stars) > 2 </li></ul><ul><li>SELECT F.filmno, F.title, S AS star </li></ul><ul><li>FROM Films F, F.star AS S </li></ul>
    15. 15. 25.3.1 Manipulating Data of Structure Types <ul><li>SELECT F.filmno, F.title, set_gen(F.star) </li></ul><ul><li>FROM Films_flat F </li></ul><ul><li>GROUP BY F.filmno, F.title </li></ul><ul><li>The operator set_gen, to be used with GROUP BY </li></ul><ul><li>The set_gen operator collects the set of star values in a partition and creates a set-valued object. This operation is called nesting. </li></ul>
    16. 16. 25.4 Objects, Object identify, and reference types <ul><li>Object Identifier (oid) </li></ul><ul><ul><li>In object-database systems, data objects can be given an object identifier, which is some value that is unique in the database across time. </li></ul></ul><ul><ul><li>DBMS is responsible for generating oids and ensuring that an oid identifies an objects and are automatically assigned unique oids. </li></ul></ul><ul><ul><li>An object’s oid can be used to refer (or ‘point’) to it from elsewhere in the data – such pointer. Ref(base): A type representing a reference to an object of type base. </li></ul></ul>
    17. 17. 25.4.1 Notations of Equality <ul><li>Two objects having the same type are defined to be deep equal if and only if: </li></ul><ul><ul><li>the objects are of atomic type and have the same value, or </li></ul></ul><ul><ul><li>the objects are of references type, and the deep equals operator is true for the two referenced objects, or </li></ul></ul><ul><ul><li>The objects are the structured type, and the deep equals operator is true for all the corresponding subparts of the two objects. </li></ul></ul>
    18. 18. 25.4.2 Dereferencing Reference Types <ul><li>An item of reference type ref(foo) is not the same as the foo item to which it points. </li></ul><ul><li>In order to access the referenced foo item, a built-in deref() method is provided along with ref type constructor. </li></ul><ul><ul><li>Nowshowing.deref(theater).name </li></ul></ul><ul><li>Java-style arrow operator </li></ul><ul><ul><li>Nowshowing.theater->name </li></ul></ul><ul><ul><li>(Fig. 25.3 of the page 741) </li></ul></ul>
    19. 19. 25.5 INHERITANCE <ul><li>In the object-database systems, unlike relational systems, inheritance is supported directly and allows type definitions to be reused and redefined very easily. </li></ul><ul><li>In object-database systems, inheritance can be used in two ways: </li></ul><ul><ul><li>for reusing and refining types and </li></ul></ul><ul><ul><li>for creating hierarchies of collections of similar but not identical objects. </li></ul></ul>
    20. 20. 25.5.1 Defining Types with Inheritance <ul><li>Inheritance allows us to capture this ‘specialization’ explicitly in the database design with the following DDL statement: </li></ul><ul><li>CREATE TYPE theatercafe_t UNDER theather_t (menu text) </li></ul><ul><li>This statement creates a new type, theatercafe_t , which has the same attributes and method as theater_t , along with one additional attributes menu of type text. </li></ul><ul><li>Method defined on theater_t apply to objects of type theatercafe_t, but not vice versa. </li></ul><ul><li>We say that theatercafe_t inherits the attributes and methods of theater_t. </li></ul>
    21. 21. 25.5.2 Binding of Method <ul><li>Consider the image_t type </li></ul><ul><li>display() will not work </li></ul><ul><li>Create jpeg_image_t, we rewrite: </li></ul><ul><ul><li>Create Function display(jpeg_image) RETURNS jpeg_image AS EXTERNAL NAME </li></ul></ul><ul><ul><li>‘ /a/b/c/jpeg.class’ LANGUAGE ‘java’; </li></ul></ul><ul><li>Registering a new method with the same name as an old method is called overloading the method name . </li></ul>
    22. 22. 25.5.1 Defining Types with Inheritance <ul><li>It creates subtype (theatercafe_t) and supertype (thaerter_t). </li></ul><ul><li>It creates an explicit relationship in the database between the subtype & supertype: An oject of the subtype is also considered to be an object of the supertype. </li></ul><ul><li>The substitution Principle: Given a supertype A and B, it is always possible to substitute an object of type B into a legal expression written for objects of type A, without producing an error. </li></ul>
    23. 23. 25.5.3 Collection Hierarchies, Type Extends and queries <ul><li>Object-oriented language such C++ & Java. </li></ul><ul><li>CREATE TABLE Theater_cafes OF TYPE theater_café_t UNDER Theaters; </li></ul><ul><li>Under clause can be used to generate an arbitrary tree of tables, called a collection hierarchy. </li></ul><ul><li>Some systems automatically create special table for each type, which contain references to every of the type that exists in the database. These tables are called TYPE EXTENDS. </li></ul><ul><li>Type extends naturally form a collection hierarchy that parallels the type hierarchy. </li></ul>
    24. 24. 25.6 Database Design for an ORDBMS <ul><li>Structured type and ADTs </li></ul><ul><ul><li>Piggy-backed (25.6.1) space probe’s location </li></ul></ul><ul><ul><ul><li>A probe id that identifies a probe uniquely </li></ul></ul></ul><ul><ul><ul><li>A video stream </li></ul></ul></ul><ul><ul><ul><li>A location sequence of (time location) pairs </li></ul></ul></ul><ul><li>What kind of a database schema should we use to store this information? </li></ul>
    25. 25. An RDBMS Database Design <ul><li>We must store each video stream as a BLOB and each location sequence as record in a table. </li></ul><ul><ul><li>Probes(pid: integer, time: timestamp, lat: real, long: real, camera: string, video: BLOB) </li></ul></ul><ul><ul><li>This is a single table called Probes, and it has several rows for each probe. </li></ul></ul><ul><ul><li>Each of these rows has the same pid, camera, and video values, but different time, lat, and long values. </li></ul></ul>
    26. 26. An RDBMS Database Design <ul><li>We have used latitude and longitude to denote location. </li></ul><ul><li>The key for this table can be represented as a functional dependency: </li></ul><ul><li>PTLN -> CV, where N stands for longitude. </li></ul><ul><li>There is another dependency: P -> CV. This relation is therefore not in BCNF, indeed, it is not even 3NF. </li></ul><ul><li>Decompose it to obtain a BCNF: </li></ul><ul><li>Probes_Loc(pid: integer, time: timestamp, lat: real long: real) </li></ul><ul><li>Probes_Video(pid: integer, camera: string, video:BLOB) </li></ul>
    27. 27. An RDBMS Database Design <ul><li>Drawbacks: </li></ul><ul><ul><li>1. Write an interface application (language) </li></ul></ul><ul><ul><li>2. It’s Obscured and dispersed across several records </li></ul></ul><ul><ul><li>3. Forced to separate the video information from the sequence information for a probe. </li></ul></ul><ul><li>We must join Probes_Loc and Probes_video using pid to achieve the result. </li></ul>
    28. 28. An ORDBMS Database Design <ul><li>An ORDBMS supports a much better solution </li></ul><ul><ul><li>1. we can store the video as an ADT object and </li></ul></ul><ul><ul><li>write method to capture </li></ul></ul><ul><ul><li>2. We can store the location sequence for a probe in a single record, along with the video information </li></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><li>Probes_AllInfo(pid:interger, locseq:location_seq, camera:string, video:mpeg_stream </li></ul></ul>
    29. 29. An ORDBMS Database Design <ul><li>This definition involves two new types: </li></ul><ul><li>location_seq and mpeg_stream </li></ul><ul><li>The mpeg_stream type is defined as an ADT, with a method display() that takes a start time and end time and displays the portion of video recorded during that interval. </li></ul><ul><li>SELECT display(P.video, 1:10 p.m. May 10 1996, 1:15 p.m May 1996. </li></ul><ul><li>FROM Probes_AllInfo P </li></ul><ul><li>WHERE P.ipd = 10 </li></ul>
    30. 30. An ORDBMS Database Design <ul><li>Now consider the location type. We could define as a list type, containing a list of ROW type objects: </li></ul><ul><li>CREATE TYPE location_listof (row (time: timesstamp, lat: real, long: real) </li></ul><ul><li>Consider the locseq field in a row for a given probe. This field contains a list of rows, each of which has three fields. </li></ul><ul><li>See Page 755. </li></ul><ul><li>SELECT P.pid, MIN(P.locseq.time) </li></ul><ul><li>FROM Probes_AllInfo P </li></ul>
    31. 31. 25.6.2 Object Identity <ul><li>There are important differences in the way that database updates affect these two types: </li></ul><ul><ul><li>Deletion </li></ul></ul><ul><ul><li>Update </li></ul></ul><ul><ul><li>Sharing versus copying </li></ul></ul><ul><li>There are also important storage distinctions between reference types and non reference types: </li></ul><ul><ul><li>Storage overhead </li></ul></ul><ul><ul><li>Clustering </li></ul></ul>
    32. 32. 25.6.2 Object Identity <ul><li>Referring objects </li></ul><ul><ul><li>By value </li></ul></ul><ul><ul><li>By reference </li></ul></ul><ul><li>In database design, the choice between using a structured type or a reference type will typically include consideration of the storage costs, clustering issues, and the effect of updates. </li></ul>
    33. 33. Object Identity versus Foreign Keys <ul><li>Using an oid to refer to an object is similar to using a foreign key to refer to a record in another relation, but not quiet the same: </li></ul><ul><li>An oid can point to an object of theater_t that is stored anywhere in the database, even in a field </li></ul><ul><li>Whereas a foreign key reference is constrained to point to an object in a particular reference relation. </li></ul>
    34. 34. 25.6.3 Extending ER Model <ul><li>Cover on Chapter 2 - Figure 25.8 </li></ul><ul><li>The definition of Probe in figure 25.8 has two aspects: </li></ul><ul><li>1. It has structure type attribute listof(row(time,lat,long)); each value assigned to this attribute in a Probes entity is a list of record with three fields. </li></ul><ul><li>2. It has an attribute called video that is an abstract data type object, which is indicated by a dark oval for this attribute with connecting it to Probes. (ADT method) </li></ul>
    35. 35. 25.6.4 Using nested Collections <ul><li>Nested collection offer great power but raise difficult design decision. </li></ul><ul><ul><li>Probe1(pid:integer, locseq:location_seq) </li></ul></ul><ul><ul><li>Probe2(pid:integer, time:timestamp, lat:real, long:real) </li></ul></ul><ul><ul><li>Can_teach1(cid:integer, teacher:setof(ssn:sting), sal: integer) </li></ul></ul><ul><ul><li>Can_teach2(cid:integer, team_id:oid, sal: integer) </li></ul></ul><ul><ul><li>Teams(tid: oid, ssn:string) </li></ul></ul>
    36. 36. 25.8 OODBMS <ul><li>Support for persistent objects </li></ul><ul><li>Support collection types (sec. 25.3) </li></ul><ul><li>Make possible to provide query language </li></ul><ul><li>(by ODMG – Object Database Mgt Group) </li></ul><ul><li>called OQL </li></ul><ul><li>OQL is similar to SQL </li></ul>
    37. 37. 25.8 OODBMS <ul><li>OQL supports </li></ul><ul><ul><li>Structure type, including sets </li></ul></ul><ul><ul><li>Bags </li></ul></ul><ul><ul><li>Arrays and </li></ul></ul><ul><ul><li>Lists </li></ul></ul><ul><ul><li>More uniform than SQL:1999 </li></ul></ul><ul><ul><li>Reference types </li></ul></ul><ul><ul><li>path expressions, ADT and Data Definition Language </li></ul></ul><ul><ul><li>Also supports nested queries </li></ul></ul>
    38. 38. 25.8 OODBMS <ul><li>There is a standard Data Definition Language for OODBMSs (Object Data Language –ODL) that is similar DDL subset of SQL but support the additional feature found in OODBMSs, such as ADT definitions. </li></ul><ul><li>25.8.1 the ODMG Data Model and SQL </li></ul><ul><li>It contains a collection of objects, which are similar to entities in the ER model. Every object has a unique oid, and a database contains collection of objects with similar properties; such a collection is called class. </li></ul>
    39. 39. 25.8.1 OQL <ul><li>Properties of a class: three kinds </li></ul><ul><ul><li>Attribute </li></ul></ul><ul><ul><li>Relationships and </li></ul></ul><ul><ul><li>method. </li></ul></ul><ul><li>Attributes - have an atomic type or structure type </li></ul><ul><ul><li>ODL supports the set, bag, list array, and structure type constructors. </li></ul></ul><ul><li>Relationships - have a type type that is either a reference to an object or a collection of such reference </li></ul>
    40. 40. 25.8.1 The ODMG data Model and ODL <ul><li>Inverse relationship </li></ul><ul><ul><li>It’s relationship “in the other direction” </li></ul></ul><ul><ul><ul><li>ShowAt </li></ul></ul></ul><ul><ul><ul><li>nowshowing </li></ul></ul></ul><ul><li>methods </li></ul><ul><ul><li>Are the functions that can be applied to objects of the class. </li></ul></ul><ul><li>The keyword interface is used to define a class. </li></ul><ul><li>For each interface we can declare an extent, which is the name for the current set of objects of that class. </li></ul>
    41. 41. 25.8.1 The ODMG data Model and ODL <ul><li>The extend is analogous to instance of a relation, and the interface is analogous to the schema. </li></ul><ul><li>See page 767. </li></ul><ul><li>Interface Movie </li></ul><ul><li>(extend Movies key movieName) </li></ul><ul><li>{attribute date start; </li></ul><ul><li> attribute date end; </li></ul><ul><li> attribute string moviename; </li></ul><ul><li>relationship Set(Theather)showAt inverse Theather::nowShowing; </li></ul><ul><li>} </li></ul>
    42. 42. 25.8.2 OQL <ul><li>The PDMG query language OQL was deliberately designed to have syntax similar to SQL. </li></ul><ul><ul><li>SELECT mname: MovieName, tname: T.theartherName </li></ul></ul><ul><ul><li>FROM Movie M, M.showAt T </li></ul></ul><ul><ul><li>WHERE T.numshowing() > 1 </li></ul></ul>
    43. 43. 25.9 RDBMS with OODBMS and ORDBMS <ul><li>An OODBMS is a programming language with a type system that supports the feature in this chapter and allows any data object to be persistent. That is, to survive across different program execution. </li></ul>
    44. 44. 25.9.1 RDBMS versus ORDBMS <ul><li>A relational system is also easier to use because there are fewer features to master. </li></ul><ul><li>- it’s less versatile than an ORDBMS </li></ul>
    45. 45. Comparing <ul><li>25,9.2 OODBMS versus ORDBMS </li></ul><ul><ul><li>similarities </li></ul></ul><ul><li>25.9.3 OODBMS versus ORDBMS </li></ul><ul><ul><li>differences </li></ul></ul>