250 likes | 422 Views
The Object Database. Object databases integrate database technology with the object-oriented paradigm In object databases, each entity of the real world is represented by an object. Classical examples of objects are: Electronic components, designed using a Computer Aided Design (CAD) system;
E N D
The Object Database • Object databases integrate database technology with the object-oriented paradigm • In object databases, each entity of the real world is represented by an object. Classical examples of objects are: • Electronic components, designed using a Computer Aided Design (CAD) system; • Mechanical components, designed using a Computer Aided Manufacturing (CAM) system; • Specifications and programs, managed in a Computer Aided Software Engineering (CASE) environment; • Multimedia documents, which includes text, images and sound, managed by multimedia document managers. --The Object Database--
Non-1NF Date • Consider the table shown below. --------------------- ACME | part | place | ------|------ | liquor| Paris | engine| Paris | ----------|---------------- DELCO | part | place | ------|------ | engine| Rome .... --The Object Database--
Un-nest and Normalise Table • The relational database solution - unnest • Normalize if necessary • ACME appears twice • What happened to structure? supplier | part | Place --------------------- ACME | liquor | Paris ACME | engine | Paris DELCO | engine | Rome .... --The Object Database--
A Data Structures Solution • Imagine a nested record structure • Variable-sized records are difficult to maintain • How to select? • No tuples, so what is the key? • Pointers are memory-only, how to store? Supplier Parts-list Parts -------- --------- ------------------ |ACME | | part1 ------> | liquor | Paris | | | | | ------------------ | parts-----------> | | ------------------ | | | part2 ------> | engine | Rome | -------- --------- --The Object Database--
A Rectangle Data Type • Database stores rectangles as four points • What does the following query do? SELECT * FROM R, S WHERE NOT(R.upperLeftX > S.lowerRightX OR S.upperLeftX > R.lowerRightX OR R.upperLeftY < S.lowerRightY OR S.upperLeftY < R.lowerRightY); • What does the following query do? SELECT * FROM R, S WHERE rectangle.overlaps(R, S); --The Object Database--
Abstract Data Type (ADT) • SQL has limited data types • New data types are useful • Polygons • Images • Sounds • video • Data type needs specifications for • Structure • Operations • Implementation • Optimization, e.g., indexing --The Object Database--
O-O Concepts - Object • Object • A uniquely identifiable entity that contains both the attributes that describe the state of a ‘real world’ object and the actions that are associated with it. • Encapsulates state • Instance variables or attributes • Complete encapsulation – can’t look inside and access variables (public vs. private) • Encapsulates behavior • Operations • Signature (specification) vs. method (implementation) --The Object Database--
O-O Concepts, cont. • Method • Block of code • Object performs method on self • Constructor, destructor • Message • Communicates request to an object • Parameters can be passed • Class • Blueprint for object • An object is an instance of a class • Inheritance • Superclasses, subclasses, overloading --The Object Database--
Definitions • OODM A logical data model that captures the semantics of objects supported in object-oriented programming. • OODB A persistent, sharable collection of objects defined by an OODM. • OODBMS The manager of an OODB --The Object Database--
Why OODB? • From programming language point of view: • permanent storage of objects (languages just support objects in memory) • sharing of objects among programs • fast, expressive queries for accessing data • version control for evolving classes and multi-person projects --The Object Database--
Why OODB? • From database point of view: • More expressive data types (traditional DBs provide limited predefined types) • e.g., a desktop publishing program might model a page as a series of frames containing text, bitmaps, and charts • need composite and aggregate data types (e.g., structures and arrays) • More expressive data relationships • many-to-one relationship (e.g., many students in one class) • navigating across relationship links • More expressive data manipulation • SQL is relationally complete but not computationally completei.e., great for searching for lousy for anything else • leads to use of conventional programming language plus SQL-interface • overhead of mapping from SQL to conventional languages • Better integration with programming languages (esp. OO languages) • Encapsulation of code with data
Two Object-oriented Approaches • Object-oriented (OODBMS) • Hellerstein - “to add DBMS capabilities to an O-O language” • Persistence, object lives beyond program execution • PJava - persistent Java • Several commercial products • Object-relational (ORDBMS) • Hellerstein - “extends a relational database with O-O features” • Rich data types • Inheritance • Several commercial vendors, SQL3 --The Object Database--
OODBMS • Advantages • Removes impedance mismatch • Long-lived transactions • Enriched modeling • Disadvanatages • Lack of universal query language • Lack of agreed upon standard • Performance depends on class definition --The Object Database--
ODMG 2. • Object Database Management Group • Consortium of Vendors: O2, ObjectStore, etc. • Standard for OODBMS • Portability • Interoperability • Comparison • Optimization • Object model • ODL • OQL --The Object Database--
Object Model • Atomic object • Any user-defined object • Class definition • Properties (attributes and structure) • (Binary) Relationships (to other objects) • Operations • Collection object • Set, array, list, etc. • Built-in • Interface (virtual object) • Inheritance • Multiple inheritance only from interfaces --The Object Database--
Object Model, cont. • Extent – named, persistent collection of objects of the same class/type • One predefined extent for each class • Key • Unique for extent • Factory object • Constructor --The Object Database--
Example Class Person { extent persons key ssn } { attribute struct { string first, string last } name; attribute integer ssn relationship Factory worksIn inverse Factory::employeeOf relationship set<Person> parentOf inverse Person::childOf; relationship set<Person> childOf inverse Person::parentOf }; --The Object Database--
Mapping EER to ODL • Entity type -> class definition • Attribute -> attribute • Many-valued -> set attribute • Composite -> struct attribute • Key -> key • Weak entity type • Composite, multi-valued attribute in owning entity type • Alternative, map to class • Inheritance • Simple, use class inheritance --The Object Database--
Mapping EER to ODL, cont. • Relationship types • Binary (no attributes) • Add relationship attributes to each side • Use sets for many • Ternary or with attributes • Map to separate class --The Object Database--
OQL • SQL-like • SELECT-FROM-WHERE • FROM clause is only major difference • Iterator variables • p in Person • Person p • Person as p • Path expressions (can appear in any clause) • “dot” notation • p.ssn • Value of attribute ssn in object denoted by iterator variable p • Same notation for following relationships (few joins!) • p.parentOf.ssn --The Object Database--
Examples • What are the social security numbers of people? SELECT s FROM person p, p.ssn s; • What are the social security numbers of children? SELECT s FROM person p, p.childOf.ssn s; • Alternatively SELECT s FROM person.childOf.ssn s; --The Object Database--
Examples • Create a structure for each social security number and last name of a grandchild whose first name is ‘Frank’. SELECT struct(last_name: g.name.last, ssn: g.ssn) FROM person p, p.childOf c, c.childOf g WHERE g.name.first = ‘Frank’; --The Object Database--
ORDBMS: Third Generation Manifesto • Rich type system • Inheritance is a good idea • Use primary key when available • Rules (triggers, constraints) are a major feature • Database access via SQL, usually embedded • SQL3 • Parts have been released, Oracle supports some SQL3 features • Collections • Recursion --The Object Database--
SQL3 DDL • Example CREATE TABLE Student (name VARCHAR(30), image GIF, phone setof{INTEGER}, ); • Phone is a set • GIF is a user-defined data type --The Object Database--
Multimedia databases • Types of multimedia data • Images • Audio • Video • Documents • Queries on multimedia data • While the coding of multimedia data is a general problem, the ability to query large amounts of multimedia data is a more specific problem of multimedia databases. • In general, it is possible to select a multimedia object only in probabilistic terms. --The Object Database--