140 likes | 367 Views
Object and object-relational databases. Object databases vs. Object-relational databases. Object databases. Object-relational databases. Relational DBMS with some object features Latest SQL standard (2008) includes some OO features Some database management systems Oracle.
E N D
Object and object-relational databases Object and object-relational databases
Object databases vs. Object-relational databases Object databases Object-relational databases Relational DBMS with some object features Latest SQL standard (2008) includes some OO features Some database management systems Oracle • Stores complex objects • Data + functions • Uses classes and objects • As in object-oriented programming: Java, C#, etc. • Some database management systems • Gemstone • Objectivity • Versant • ObjectStore Object and object-relational databases
Object identity • Every object in a object database must have a unique identity. • Called object identity (OID) • ID’s in relational databases must be unique within the table only. • OID generated by DBMS • OID must be immutable • Literals (simple values) have no OID Object and object-relational databases
Complex type structures • Atoms • Single value types, like string, int, etc. • Struct aka. Tuple • Type generator: Heterogeneous members (different types) • Examples • Struct Name<firstname: string, lastname: string> • Struct Student<name: Name, address: string> • Collection aka. Multi-valued • Type generator: Homogeneous members (same type) • Set(T), List(T), bag(T), array(T), dictionary(T) • Sub-types • You can define a sub-type of a struct by extending the struct. Object and object-relational databases
Collections • Set(T) • Distinct members, duplicates not allowed • Java: Set<T> • Bag(T) • Duplicates members allowed • Java: Collection<T> • List(T) • Duplicates members allowed. Unlimited capacity • Ordered list • It makes sense to ask for 1st element, 2nd element, etc. • Order, is not necessarily sorting order • Java: List<T> • Array(T) • Like List(T), but Array(T) has a maximum size Object and object-relational databases
Example: Defining complex types Object and object-relational databases
Example: Defining complex types with operations Object and object-relational databases
Object-Relational databases • Object-relational database • Add some object oriented features to an otherwise relational database • Type constructors • Object identity • Operations • Inheritance / sub-types • Tables creates using simple types + ”homemade” types • Example Object-relational DBMS • Oracle has many OO features • Microsoft SQL Server has no OO features Object and object-relational databases
ODMG Object model and ODL • ODMG =Object Data Management Group • Standard committee for Object oriented databases • ODMG 1.0, 2.0, 3.0 • Object model • ODL = Object Definition Language • ODL terms • Extent: Contains the persistent objects of a class • Key: One or more properties (attributes or relationships) • Factory object: similar to constructor in object-oriented programming Object and object-relational databases
ODMG database schema Object and object-relational databases
ODMG ODL example Object and object-relational databases
Object Query Language (OQL) • Defined by ODMG • Writing queries for the ODMG object model • Basic structure • Select … from … where • As in ordinary SQL • Example Select D.name from D in Departments where D.college = ’Engineering’ • Departments is an ’extent’ • D is a so-called iterator variable Object and object-relational databases
Object-relational mapping (ORM) • Alternative to object databases and object-relational databases • ORM programming technique to convert data between object-oriented programming languages and relational databases. • A virtual object database • Some frameworks • Hibernate for Java • NHibernate for Microsoft .NET • ADO.NET Entity Framework for Microsoft.NET Object and object-relational databases