1 / 43

Object-oriented & object-relational databases

Object-oriented & object-relational databases. CS561-Spring 2014 WPI, Mohamed eltabakh. Stonebraker ’ s Application Matrix. Motivation. Relational model (70 ’ s): Clean and simple. Great for administrative and transactional data.

dhauser
Télécharger la présentation

Object-oriented & object-relational databases

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object-oriented & object-relational databases CS561-Spring 2014 WPI, Mohamed eltabakh

  2. Stonebraker’s Application Matrix

  3. Motivation • Relational model (70’s): • Clean and simple. • Great for administrative and transactional data. • Not as good for other kinds of complex data (e.g., multimedia, networks, CAD). • Object-Oriented models (90’s): • Complicated, but some influential ideas from Object Oriented • Complex data types. • Idea: Build DBMS based on OO model. Programming languages have evolved from Procedural to Object Oriented. So why not DBMSs ???

  4. Relational model of a ‘cat’ At query time, try to put things together as you want !!!!

  5. Object Oriented model of a ‘cat’ : Computer aided software engineering : Computer aided design : Computer aided manufacture

  6. Two approaches • Object-Oriented Model (OODBMS) • Pure OO concepts • Object-Relational Model (ORDBMS) • Extended relational model with OO concepts

  7. Database design process ERD

  8. Logical & physical layers ER diagram

  9. Example of ERD

  10. Example of UML Classes

  11. Example 2 Connecting several UML Classes Each Enrollment object consists of Two objects (student & section) UML: Unified Modeling Language

  12. UML Diagrams • Class Diagram • Describe the classes and relationships • Instance or Object Diagram • Describes the actual instances

  13. UML: Class Diagram Each object is self-contained An order has the cust. Info + the product Info

  14. UML: Instance Diagram

  15. Object-Oriented Model

  16. First approach: object-oriented model • Relations are not the central concept, classes and objects are the main concept • Object-Oriented DBMS(OODBMS) are DBMS based on an Object-Oriented Data Model inspired by OO programming languages • Main Features: • Powerful type system • Classes • Object Identity • Inheritance • OODBMS are capable of storing complex objects, I.e., objects that are composed of other objects, and/or multi-valued attributes.

  17. Feature 1: powerful type system • Primitive types • Integer, string, date, Boolean, float, etc. • Structure type • Attribute can be a recordwith a schema • Collection type • Attribute can be a Set, Bag, List, Array of other types • Reference type • Attribute can be a Pointerto another object Struct {integer x, string y}

  18. Feature 2: Classes • A ‘class’ is in replacement of ‘relation’ • Same concept as in OO programming languages • All objects belonging to a same class share the same properties and behavior • An ‘object’ can be thought of as ‘tuple’ (but richer content) • Classes encapsulate data + methods + relationships • Unlike relations that contain data only • In OODBMSs objects are persistency (unlike OO programming languages)

  19. Feature 3: object identity • OID is a unique identity of each object regardless of its content • Even if all attributes are the same, still objects have different OIDs • Easier for references • An object is made of two things: • State: attributes (name, address, birthDate of a person) • Behaviour: operations (age of a person is computed from birthDate and current date)

  20. Person name: {firstName: string, middleName: string, lastName: string} address: string birthDate: date age(): Integer changeAddress(newAdd: string) Student regNum: string {PK} major: string register(C: Course): boolean Feature 4: Inheritance • A class can be defined in terms of another one. • Person is super-class and Student is sub-class. • Student class inherits attributes and operations of Person.

  21. Standards for object-oriented model • ODMG: Object Data Management Group (1991) • provide a standard where previously there was none • support portability between products • standardize model, querying and programming issues • Language of specifying the structure of object database • ODL: Object Definition Language • OQL: Object Query Language • ODL is somehow similar to DDL (Data Definition Language) in SQL

  22. Overview of ODL & OQL

  23. ODL: classes & attributes Keyword attribute Two classes with their attributes Attribute as a structure

  24. ODL: relationships Keyword relationship Keyword set Set: set of unsorted unique objects Bag: set of unsorted objects with possible duplication List: set of sorted list Array: set of sorted list referenced by index

  25. ODL: relationships Now a movie object has the stars What about the star object ???

  26. ODL: relationships & inverse relationships Keyword inverse Refers to Inverse relationship means: If movie M1 has star S1 Then star S1 must have movie M1

  27. ODL: relationships & inverse relationships Keyword inverse Refers to Inverse of each other

  28. ODL: Multiplicity of Relationships Based on the use of collection types (set, bag, etc.) Many-to-Many relationship One-to-Many relationship What about multiway relationships??? --Not supported --Need to convert a multiway to multiple binary relationships

  29. ODL: methods Three methods declarations Parameters are either IN, OUT, or INOUT Definition (implementation) is not part of the class

  30. ODL: Inheritance • Same Idea as in OO programming (C++ or Java) • Subclass inherits all attributes, relationships, and methods • Plus adding additional fields Keyword extends Cartoon movie is a movie with voices of characters Murder movie is a movie with the weapons used Inherits from two other classes

  31. ODL: Instances & Keys • Instance of a class are all objects currently exist of that class • In ODL that is called extent(and is given a name) • Keys are not as important for referencing objects • Because each object already has a unique OID • Defining keys in ODL is optional • ODL allows defining multiple keys (Comma separated) Keywords extent &key The key is the pair of (title, year) The key is the pair of (empID, SSN) Two keys empID and SSN

  32. What’s next • First Approach: Object-Oriented Model • Concepts from OO programming languages • ODL: Object Definition Language • What about querying OO databases??? • OQL: Object Oriented Query Language

  33. OQL: Object-oriented query language • OQL is a query language designed to operate on databases described in ODL. • Tries to bring some concepts from the relational model to the ODBMs • E.g., the SELECT statement, joins, aggregation, etc. • Reference of class properties (attributes, relationships, and methods) using: • Dot notation (p.a), or • Arrow notation (p->a) • In OQL both notations are equivalent

  34. Example

  35. Q1

  36. Q2

  37. Example 2 Reference the extent (instance of class) Select the year of movie ‘Gone with the wind’ For each movie m, s is the set of stars in that movie (follow a relationship) Select star names from movie ‘Casablanca’ Another notation

  38. OQL: Example Queries II Select distinct star names in movies owned by ‘Disney’ subquery order movies owned by ‘Disney’ based on length and title Report set of structures Join two classes Report pairs of stars who have the same address

  39. OQL Output • Unlike SQL which produces relations, OQL produces collection (set, bag, list) of objects • The object can be of any type Set of strings Set of objects of type Movie Set of structures

  40. Oql: Aggregation Aggregate over the partition Intermediate result Struct{ stdo: …, yr: …, partition: bag(struct {m: …}) }; Grouping fields Bag of structures with members follow what’s in the FROM clause

  41. OQL: Collection operators • Like in SQL, we have ANY, ALL, EXISTS • OQL has similar operators Select stars who participated in a movie made by ‘Disney’ Select stars who participated only in movies made by ‘Disney’

  42. Integrating oql & external languages • OQL fits naturally in OO host languages • Returned objects are assigned in variables in the host program Variable in host language (C++ or Java) Array of objects of type Movie Iterate over the list in a natural way

  43. OQL summary

More Related