Chapter - 1 Object-Oriented & Objectrelational Databases
Chapter - 1 Object-Oriented & Objectrelational Databases
Chapter - 1 Object-Oriented & Objectrelational Databases
Chapter one
1
Objectives
2
Definition of Terms
Database
The DBMS software together with the
System:
data itself.
3
Types of DBMS Models
4
Hierarchical Database Model.
• In a Hierarchical database model, the
data is organized in a tree-like
structure.
• Data is Stored Hierarchically (top
down or bottom up) format.
• Data is represented using a parent-
child relationship that are one to one
or one to many.
• In Hierarchical DBMS parent may
have many children, but children have
only one parent.
5
Network Database Model
• The network database model allows each child to have multiple parents.
• More complex relationships such as the orders/parts many-to-many
relationship.
• The entities are organized in a graph which can be accessed through
several paths.
6
Relational Database Model
• Most widely used DBMS model
• Easiest
• Based on normalizing data in the rows and columns of the tables.
• Data is stored in fixed structures and manipulated using SQL.
7
Relational model (70’s):
Clean and simple.
8
What is missing??
Handling of complex objects
Handling of complex data types
Code is not coupled with data
No inherence, encapsulation, etc.
9
Object-Oriented Database Model
• In Object-oriented Model data stored in the form of objects.
• The structure which is called classes which display data within it.
• It defines a database as a collection of objects which stores both data
members values and operations.
10
Object-Oriented models (80’s):
Programming languages
Idea: Build DBMS have
based on evolved from Procedural to Object
OO model.
Oriented. So why not DBMSs ???
• Properties
• Name
• Height
• Weight……..
• Behaviors
• Eat
• Pray
• Walk …..
Application areas
12
OO vs. EER Data Modeling
Object Oriented EER
Class Entity type
Object Entity instance
Association Relationship
Inheritance of attributes Inheritance of attributes
Inheritance of behavior No representation of
behavior
14
OO concepts (mandatory concepts)
The Golden Rules/1 DBMS concepts (mandatory concepts)
Complex objects The Golden Rules/2
Persistence
Object identity
Secondary storage management
Encapsulation Concurrency
Recovery
Types and/or Classes
Ad Hoc Query Facility
Class or Type Hierarchies
Overriding, overloading
Computational completeness
Distribution
Design transactions
Versions
16
Two approaches of Object oriented DB
Object-Oriented Model (OODBMS)
Pure OO concepts
17
Object Data Management Group(ODMG )
ODMG— to define standards for OODBMSs.
behavior (operations).
19
ODMG Objects and Literals
The basic building blocks of the object model are:
Objects
Literals
Objects are described by four characteristics
1. Identifier : unique system wide identifier.
2. Name : is used to refer the objects. It is optional
3. Life time
Transient - unstable and can be updated and deleted
Persistent – permanent object like (oodb)
Naming – giving name
Reachable- Collecting similar objects under one name.
4. Structure: specifies how the object is constructed by using type constructors
It also Specifies whether the object is atomic or collection type
21
Objects type
In ODBs, a complex type may be constructed from other
Atom,
Collection.
22
Atomic constructors
23
struct (or tuple) constructor
Create standard structured types, such as the tuples (record
types) in the basic relational model.
Referred to as a compound or composite type
Example
24
Collection (or multivalued)
Collection is used to create complex nested type structures in
the object model.
Collection type constructors includes;
Set(T),
List(T),
Bag(T),
Array(T), and
25
Collection Objects(types)
Set<T>: unordered collections that do not allow duplicates.
used to create objects such that the value of the object is set
whose elements are of type T.
Operations : Intersection, union, & set difference.
Bag<T>: allows duplicate elements in the collection and also inherits the
collection interface.
26
Con…
List<T>: create collections where the order of the elements is
important.
The value of object is an ordered list whose elements are of type
T.
We can refer to the first, last, and ith element in the list.
Operations
O.insert_element_first(E)— inserts the element E before the first
element in the list O.
O.insert_element_last(E) &
O.insert_element_after(E, I)—inserts the element E after the ith
element in the list O and Raise the exception InvalidIndex if no ith
element exists in O.
E = O.remove_first_element(),
E = O.remove_last_element(), and
27 E = O.remove_element_at(I) remove the indicated element from the
Con…
E = O.retrieve_first_element(),
E = O.retrieve_last_element(), and
Operations
O.replace_element_at(I, E) replaces the array element at position
I with element E;
E = O.remove_element_at(I) retrieves the ith element and
replaces it with a NULL value; and
E = O.retrieve_element_at(I) simply retrieves the ith element of
the array.
Any of these operations can raise the exception InvalidIndex if I is
greater than the array’s size.
O.resize(N) changes the number of array elements to N.
29
Con…
Dictionary<K,V>: allows the creation of a collection of
association pairs <K,V>, where all K (key) and V(values) are
unique.
Operations
31
Object types
Example:
Date object – can generate many calendar dates
Ethiopian calendar
European calendar
Arabic calendar
Indian calendar
Attributes
34
Relationships
35
Relationships
36
Relationships
37
Operations
A function or service that is provided by all instances of a class
Types of operations:
Constructor: creates a new instance of a class
Query: accesses the state of an object but does not alter its
state
Update: alters the state of an object
42Interface is Noninstantiable
Classes
Class defines both the abstract state and behavior of an object
type.
Class is instantiable (thus, interface is an abstract concept and
class is an implementation concept).
Use the extends keyword to specify single inheritance between
classes. Multiple inheritance is not allowed.
Classes encapsulate data + methods + relationships
encapsulation.
Information hiding-- separate the external aspects of an object
from its internal details, which are hidden from the outside world.
45
Focus more on data security
Encapsulation
To encourage encapsulation, an operation is defined in
two parts.
Signature or interface of the operation specifies the operation
name and arguments (or parameters).
Method or body specifies the implementation of the operation,
General purpose programming language.
46
Inheritance
Person
A class can be defined in terms of another one.
name: {firstName: string,
middleName: string,
Allows the definition of new types based on other lastName: string}
address: string
predefined types, leading to a type (or class) birthDate: date
age(): Integer
hierarchy. changeAddress(newAdd: string)
Example
operations of Person.
47
Types of inheritance(Multiple and Selective Inheritance)
This leads to the creation of a type lattice rather than a type hierarchy.
Overloading –
allows the name of a method to be reused within a class
definition.
Overriding –
51
Versioning
The process of maintaining the evolution of objects is known as
version management.
An object version represents an identifiable state of an object;
a version history represents the evolution of an object.
Versioning should allow changes to the properties of objects to
be managed in such a way that object references always point
to the correct version of an object.
52
Overview of ODL & OQL
The Object Definition Language (ODL) is a language for
defining the specifications of object types for ODMG-compliant
systems.
53
Overview of ODL & OQL
The Object Query Language (OQL) provides declarative
access to the object database using an SQL-like syntax.
54
Querying object-relational database
Most relational operators work on the object-relational tables
55
Defining Generalization
OQL following the given classes;
Con…
Suppose we want to find the title and credit hours for MBA 664.
This query traverses two paths, one using the takes relationship and the other using
the belongs_to relationship, to find the codes and titles of all courses taken by Mary
Jones.
• select c.crse_code, c.crse_title from students s, s.takes x, x.belongs_to
c where s.name = “Mary Jones”;