Download Object and object-relational databases

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Concurrency control wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Clusterpoint wikipedia , lookup

Database wikipedia , lookup

Relational model wikipedia , lookup

Versant Object Database wikipedia , lookup

Database model wikipedia , lookup

Transcript
Object and object-relational
databases
Object and object-relational databases
1
Object databases vs.
Object-relational databases
Object databases
• 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-relational databases
• Relational DBMS with some
object features
• Latest SQL standard (2008)
includes some OO features
• Some database
management systems
– Oracle
Object and object-relational databases
2
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
3
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
4
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
5
Example: Defining complex types
Object and object-relational databases
6
Example: Defining complex types
with operations
Object and object-relational databases
7
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
8
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 objectoriented programming
Object and object-relational databases
9
ODMG database schema
Object and object-relational databases
10
ODMG ODL example
Object and object-relational databases
11
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
12
Object-relational mapping (ORM)
• Alternative to object databases and objectrelational 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
13