0% found this document useful (0 votes)
64 views51 pages

ADMS Chapter One

This document provides an introduction to object-oriented databases. It discusses what data and databases are, and the benefits of using a database management system. It then describes different types of databases, including hierarchical, network, relational, and object-oriented databases. Key aspects of object-oriented databases are explained, such as object identity, structure, and type constructors like atom, tuple, and collection. The goal of object-oriented databases is to directly store objects from object-oriented programming languages.

Uploaded by

Gomlalaw tube
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views51 pages

ADMS Chapter One

This document provides an introduction to object-oriented databases. It discusses what data and databases are, and the benefits of using a database management system. It then describes different types of databases, including hierarchical, network, relational, and object-oriented databases. Key aspects of object-oriented databases are explained, such as object identity, structure, and type constructors like atom, tuple, and collection. The goal of object-oriented databases is to directly store objects from object-oriented programming languages.

Uploaded by

Gomlalaw tube
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 51

COSC 266

ADVANCED DATABASE
MANAGEMENT SYSTEM

Instructor : Yohannes K
Chapter 1
Object-oriented Database

CoSc 266 : Advanced Database management System


Instructor : Welde Janfa
Introduction
 Data
 Data is known facts that can be recorded and that have implicit
meaning.
For example
 Name of Employee

 Address of Employee etc…

 Data can be recorded in an indexed address book or it can be


stored on a hard drive, using a personal computer and software
such as Microsoft Access or Excel
Introduction
 Database
• A collection of related data with an implicit meaning
.
• A database has the following implicit properties:
 A database represents some aspect of the real

world, sometimes called the mini-world


 A database is a logically coherent collection of

data with some inherent meaning.


 A database is designed, built, and populated with

data for a specific purpose.


 It has an intended group of users and some

preconceived applications in which these users


are interested.
Introduction
 DBMS
 A database management system (DBMS) is a collection of
programs that enables users to create and maintain a database.
 The DBMS is a general-purpose software system that facilitates
the processes of defining, constructing, manipulating, and
sharing databases among various users and applications.
 There are two operation in DBMS
 DDL and
 DML

• Microsoft SQL, Oracle , MySQL, DB2,


Introduction
Types of Database
 File based system
 Adequatefor small business
 Drawback
 Separation and Isolation of Data
 Each program/ Department store and maintain its own data

 A user of one program may not aware the important of the other

data
 Duplication of Data

 Wasted time and space


 Data Dependency

 Incomputable file format

 Difficulty in accessing and querying data since a new program has to

be written to carry out each new task.


Introduction
–Types of Database
 Database based System

 Database systems solve all problems of file systems


 Data independence (logical, physical)
 Data integration
 Data consistency, lack of data redundancy
 Concurrent access, transactions, recovery, backup
 Querying (SQL)
Introduction – Types of Database
 Hierarchical/Network Database Model
 Suitable for data which are related
 Hierarchically start by defined tree of data node
 Each node can contain some identifying data, plus a set of sub-
nodes of a specific child type

 Relational Database
 Provides a conceptually simple model for data as relations (typically
considered “tables”) with all data visible.
Introduction – Types of Database
 Object Oriented Database Model

Goal:
Store object-oriented programming objects in a database
without having to transform them into relational format
OODB were not commercially successful due to
 high cost of relational to object-oriented transformation and a sound
underlying theory, but they still exist
 as mentioned creating a standard.

This was attempted by the Object Data Management Group (ODMG)


which published five revisions to its standard. This group was wound
up in 2001.
Introduction – Types of Database
OODBMS

Hierarchical Data Model

Network Data Model

Relational Data Model

ER Data Model

Semantic Data Model

Object-Relational Data Model Object Oriented Data Model


Object Oriented Database
 Why Object Oriented database?
1. Traditional data models and systems, such as relational,
network, and hierarchical, have been quite successful in
developing the database technologies required for many
traditional business database applications.
However, they have certain shortcomings when more complex
database applications must be designed and implemented—for
example, databases for engineering design and manufacturing
(CAD/CAM and CIM1), scientific experiments,
telecommunications, geographic information systems , and
multimedia
Object oriented database was proposed to meet some of the needs of
these more complex applications that store images, videos or large
textual items
Object Oriented Database
2. Vast increase in the use of object-oriented programming languages for
developing software applications.
• Traditional databases are sometimes difficult to use with software applications
that are developed in an object-oriented programming language such as C++
or Java.
• In traditional database systems, information about a complex object is often
scattered over many relations or records, leading to loss of direct
correspondence between a real-world object and its database representation.
• Programming language and database data types and data definition are
completely different (an “impedance mismatch”)
• Object databases are designed so they can be directly—or seamlessly—
integrated with software that is developed using OOPLs.

 The traditional DBMS /RDBMS software become object database


management systems (ODMS) or ODBMS or OODBMS in object
oriented database implementation.
Object
 The Object oriented (OO or O-O) has originated in OO
programming language or OOPLs such as Java, C++
 But now a days OO concept is applied in the area of
Database, Software engineering, Knowledge base,
Artificial intelligence, and computer system in general
 What is Object ?
 Object consists of entity and attributes which can describe the
state of real world object and action associated with that
object.
 An object typically has two components: state (value) and
behavior (operations)
Characteristics of Object

 Object name
The name is used to refer different objects in the program.
 Object identifier
This is the system generated identifier which is assigned,
when a new object is created.
 Structure of object
Structure defines, how the object is constructed using
constructor.
 In object oriented database the state of complex object can be

constructed from other objects by using certain type of constructor.


 The formal way of representing objects as (i,c,v) where 'i' is object

identifier, 'c' is type constructor and 'v' is current value of an object.


Characteristics of Object

 Transient object
 In OOPL, objects which are present only at the time of

execution are called as transient object.


 For example: Variables in OOPL

 Persistent objects

An object which exists even after the program is


completely executed (or terminated), is called as persistent
objects. Object-oriented databases can store objects in
secondary memory.
In other words, OO databases store persistent objects
permanently in secondary storage, and allow the sharing of
these objects among multiple programs and applications
Object Identity
 One goal of an ODMS (Object Data Management System)
is to maintain a direct correspondence between real-world
and database objects so that objects do not lose their
integrity and identity.
 Hence, an ODMS provides a unique identity to each
independent object stored in the database
 Each object is assigned an Object Identifier (OID) when
it is created that is:
 system generated
 unique to that object
 immutable / invariant/ unchanged
 independent of the values of its attributes
 indivisible to the user
 used only once.
Object Structure
 Similar to Object Oriented Programming, OODB objects
can be constructed from other object constructors.
 An object can be defined as a triple (i,c,v) . Where
i is the object identifier,
c is the type constructor, and
v is the state or value of the object.
Type Constructors
In ODMS objects and literals may have a type structure of
arbitrary complexity in order to contain all of the necessary
information that describes the object
 The three most basic type constructors (types) are atom, tuple,
and collection.
Atom Constructor
 One type constructor has been called the atom constructor,
 The atom constructor is used to represent all basic atomic values,
such as integers, real numbers, character strings, Booleans, and any
other basic data types that the system supports directly.
 They are called single-valued or atomic types, since each value of
the type is considered an atomic (indivisible) single value.
Type Constructors
Tuple (Struct) constructor
 struct (or tuple) constructor. This can create standard structured
types, such as the tuples (record types) in the basic relational
model.
 A structured type is made up of several components, and is also
sometimes referred to as a compound or composite type.
For example, two different structured types that can be created are:
struct Name<FirstName: string,
MiddleInitial: char,
LastName: string>,
struct CollegeDegree <Major: string,
Degree: string,
Year: date>
Type Constructors
Collection (or multivalued) Constructor
 Collection constructors include the set(T), list(T), bag(T), array(T),
and dictionary(K,T) type constructors.
 These allow part of an object or literal value to include a collection
of other objects or values when needed.
 These constructors are also considered to be type generators
because many different types can be created.
For example,
 set(string), set(integer), and set(Employee) are three different types
that can be created from the set type constructor. All the elements in
a particular collection value must be of the same type. For example,
all values in a collection of type set(string) must be string values.
Type Constructors
 Atom constructor is used to represent all basic atomic values,
such as integers, real numbers, character strings, Booleans,
and any other basic data types that the system supports
directly.
 The tuple constructor can create structured values and objects
of the form <a1:i1, a2:i2,...,an:in>, where each aj is an attribute
name and each ij is a value or an OID
 The other commonly used constructors are collectively
referred to as collection types, but have individual differences
among them.
Type Constructors
 The set constructor will create objects or literals that are a set of
distinct elements {i1,i2,...,in},all of the same type.
 The bag constructor (sometimes called a multiset) is similar to a set
except that the elements in a bag need not be distinct.
 The list constructor will create an ordered list [i 1,i2,...,in] of OIDs or
values of the same type.
 A list is similar to a bag except that the elements in a list are
ordered, and hence we can refer to the first, second, or j th element.
 The array constructor creates a single-dimensional array of
elements of the same type. The main difference between array and
list is that a list can have an arbitrary number of elements whereas
an array typically has a maximum size.
 The dictionary constructor creates a collection of two tuples (K,
V), where the value of a key K can be used to retrieve the
corresponding value V.
Type Constructors
Object state interpreted by object constructors
Object Structure
Object structure can be defined by constructor
 Atomic
 Structured (tuple)
 Collection : set , List , bag, array

Example

i1, i2, i3, . . . to stand for unique system generated object identifiers. Consider the following
objects:

o1 = (i1, atom, ‘AddisAbaba’)

o2 = (i2, atom, ‘Jemo’)

o3 = (i3, atom, ‘Jimma’)

o4 = (i4, atom, 5)

o5 = (i5, atom, ‘Research’)

o6 = (i6, atom, ‘1988-05-22’)

o7 = (i7, set, {i1, i2, i3})


Object Structure

Example 1 (cont.)
 The first six objects listed in this example
represent atomic values.

 Object 7 is a set-valued object that represents the


set of locations for department 5; the set refers to
the atomic objects with values {‘AddisAbaba’,
‘Jemo’, ‘Jimma’}.
Object Structure
Example 1 (cont.)
o8 = (i8, tuple, <dname:i5, dnumber:i4, mgr:i9,
locations:i7, employees:i10, projects:i11>)
o9 = (i9, tuple, <manager:i12, manager_start_date:i6>)
o10 = (i10, set, {i12, i13, i14})
o11 = (i11, set {i15, i16, i17})
o12 = (i12, tuple, <fname:i18, minit:i19, lname:i20, ssn:i21, . .
., salary:i26, supervi-sor:i27, dept:i8>)

Object 8 is a tuple-valued object that represents


department 5 itself, and has the attributes DNAME,
DNUMBER, MGR, LOCATIONS, and so on.
Equal vs. Identical Objects
 Two objects are said to have identical values,
if the graphs representing their values are
identical in every respect, including the OIDs
at every level.
 Two object are said to have equal values if
their graph structure is the same, all the
corresponding atomic values should also be the
same (same states at the atomic level) but their
OID do not have to be the same.
Equal vs. Identical Objects
 Example 2:
This example illustrates the difference between the two
definitions for comparing object states for equality.
o1 = (i1, tuple, <a1:i4, a2:i6>)
o2 = (i2, tuple, <a1:i5, a2:i6>)
o3 = (i3, tuple, <a1:i4, a2:i6>)
o4 = (i4, atom, 10)
o5 = (i5, atom, 10)
o6 = (i6, atom, 20)

In this example, The objects o1 and o2 have equal states,


since their states at the atomic level are the same but the
values are reached through distinct objects o4 and o5.
Equal vs. Identical Objects
Example 2 (cont.):
However, the states of objects o1 and o3 are
identical, even though the objects themselves are
not because they have distinct OIDs.
Similarly, although the states of o 4 and o5 are
identical, the actual objects o4 and o5 are equal
but not identical, because they have distinct
OIDs.
Type Constructors
Specifying the object types Employee, date, and Department using type
constructors
1.5 Encapsulation of Operations
Encapsulation
 One of the main characteristics of OO languages and systems
 related to the concepts of abstract data types and information hiding
in programming languages
 In relational database, the concept encapsulation was not applied,
since all tuple is visible to all users of the database.
 For example, in the relational model, the operations for selecting,
inserting, deleting, and modifying tuples are generic and may be
applied to any relation in the database

 Specifying Object Behavior via Class Operations:


 The main idea is to define the behavior of a type of object based on
the operations that can be externally applied to objects of that type.

 For database applications, the requirement that all objects be


completely encapsulated is too stringent.
 One way of relaxing this requirement is to divide the structure of an
object into visible and hidden attributes (instance variables).
Encapsulation in OODBs
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.

 Operations can be invoked by passing a message to an


object, which includes the operation name and the
parameters.
 The object then executes the method for that operation.
Encapsulation in OODBs
 Some operations used to create (insert) or destroy (delete)
objects or update the object state or retrieve parts of the
object state or to apply some calculations or perform a
combination of retrieval, calculation, and update
 Encapsulation permits modification of the internal structure
of an object, as well as the implementation of its operations,
without the need to disturb the external programs that invoke
these operations.
 The external users of the object are only made aware of the
interface or signature of the operations, which defines the
name and arguments (parameters) of each operation
Encapsulation in OODBs
Adding operations to definitions of Employee and Department:
Encapsulation in OODBs
 The number operation are declared for each class, and the
signature (interface) of each operation is included in the
class definition.
 A method (implementation) for each operation must be
defined elsewhere using a programming language
 Object constructor operation (often called new), which is
used to create a new object, and the destructor operation,
which is used to destroy (delete) an object.
 An operation is typically applied to an object by using the
dot notation.
For example,
 if d is a reference to a DEPARTMENT object, we can invoke an
operation such as no_of_emps by writing d.no_of_emps.
Similarly, by writing d.destroy_dept, the object
1.6 Methods and Persistence
 Specifying Object Persistence via
 Naming and
 Reachability

Naming
 The naming mechanism involves giving an object a unique
persistent name within a particular database.

 Itis not practical to give names to all objects in a large database ,


so objects are made persistent by using the second mechanism
called reachability
Reachability
 The reachability mechanism works by making the object
reachable from some other persistent object.
 An object B is said to be reachable from an object A if a sequence
of references in the database lead from object A to object B.
Methods and Persistence
Creating persistent objects by naming and reachability
1.7 Type Hierarchies and Inheritance
Inheritance allows the definition of new types based on other
predefined types, leading to a type(or class) hierarchy.
A type is defined by assigning it a type name, and then
defining a number of attributes (instance variables) and
operations (methods) for the type

Type (class) Hierarchy


 A type in its simplest form can be defined by it’s type name and a
listing of the names of its visible/public functions. Attributes
(instance variables) and operations (methods) for the type are
together called functions

 TYPE_NAME: function, function, . . . , function


1.7 Type Hierarchies and Inheritance
For example a type that describe a character of person

Example: PERSON: Name, Address, Birthdate, Age

Name, Address ,and Birth_date functions can be implemented as stored


attributes, whereas the Age function can be implemented as calculated
value.

Subtype: when the designer or user must create a new type that is similar but
not identical to an already defined type

Subtype: inherits all the functions of the predefined type (also known as the
super type)
1.7 Type Hierarchies and Inheritance
Type (class) Hierarchy
Example (1):
PERSON: Name, Address, Birthdate, Age, SSN

EMPLOYEE: Name, Address, Birthdate, Age, Salary, Hire_Date,


Seniority

STUDENT: Name, Address, Birthdate, Age, Major, GPA OR:


Therefore, we can declare EMPLOYEE and STUDENT as
follows:
EMPLOYEE subtype-of PERSON: Salary, Hire_Date, Seniority

STUDENT subtype-of PERSON: Major, GPA


1.7 Type Hierarchies and Inheritance
Type (class) Hierarchy
A subtype includes all of the functions that are defined for its
supertype plus some additional functions that are specific only
to the subtype.

Hence, it is possible to generate a type hierarchy to show the


supertype/subtype relationships among all the types declared
in the system.
1.7 Type Hierarchies and Inheritance
Type (class) Hierarchy
Example (2):
consider a type that describes objects in plane geometry, which may be
defined as follows:

GEOMETRY_OBJECT type: Shape, Area, ReferencePoint

Now suppose that we want to define a number of subtypes for the


GEOMETRY_OBJECT type, as follows:

RECTANGLE subtype-of GEOMETRY_OBJECT: Width, Height


TRIANGLE subtype-of GEOMETRY_OBJECT: Side1, Side2, Angle
CIRCLE subtype-of GEOMETRY_OBJECT: Radius
1.7 Type Hierarchies and Inheritance
Type (class) Hierarchy
Example (2):
Notice that the Area operation may be implemented by a different
method for each subtype,

since the procedure for area calculation is different for rectangles,


triangles, and circles.

Similarly, the attribute Reference_point may have a different meaning


for each subtype;

it might be the center point for RECTANGLE and CIRCLE objects,


and the vertex point between the two given sides for a TRIANGLE
object.
1.7 Type Hierarchies and Inheritance
Type (class) Hierarchy
Example (2) (cont.):
An alternative way of declaring these three subtypes is to specify
the value of the Shape attribute as a condition that must be
satisfied for objects of each subtype:

RECTANGLE subtype-of GEOMETRY_OBJECT


(Shape=‘rectangle’): Width, Height

TRIANGLE subtype-of GEOMETRY_OBJECT (Shape=‘triangle’):


Side1, Side2, Angle

CIRCLE subtype-of GEOMETRY_OBJECT (Shape=‘circle’): Radius


1.8 Polymorphism
 Polymorphism is another characteristics of OO system that
provide two or more function using one method.
 It allows the same operator/Method name or symbol to bound
(give)to two or more different implementation of operation ,
depending on the type of object to which the operator is
applied.
 Polymorphism also called operator overloading

 Polymorphism can be applied using method overloading or


method overriding.
1.8 Polymorphism
Example 2
STAFF_OBJECT type: salary,
void givecommission(float profit) {
Salary=salary+0.02*profit; }

Manager subtype-of STAFF_OBJECT :


void givecommission(float profit) {
salary=salary+0.05*profit; }

we might define a method in the staff class to increment salary


However we may wish to perform a different calculation for
commission in manager subclass, we can do this by redefine the
method givecommission in manager sub object as shown above and
called method overriding
1.8 Polymorphism
Example 1- Overloading
GEOMETRY_OBJECT type: Shape, Area, ReferencePoint

RECTANGLE subtype-of GEOMETRY_OBJECT

(Shape=‘rectangle’): Width, Height

TRIANGLE subtype-of GEOMETRY_OBJECT (Shape=‘triangle’):


Side1, Side2, Angle

CIRCLE subtype-of GEOMETRY_OBJECT (Shape=‘circle’): Radius


1.9 MULTIPLE AND SELECTIVE INHERITANCE
Multiple inheritance
Multiple inheritance refer that the subclass inherit from more than one
superclasses.
Example:

Manager salesStaff

salesManager

 The multiple inheritance is very problematic . The conflict arises


when the superclasses contain the same attributes or method.
 It can be handled by the following ways:
 Include both attributes/method and use the name of the superclass as
qualifier
1.9 MULTIPLE AND SELECTIVE INHERITANCE
Multiple inheritance
There are several techniques for dealing with ambiguity in
multiple inheritance.
1. One solution is to have the system check for ambiguity when
the subtype is created, and to let the user explicitly choose
which function is to be inherited at this time.
2. A second solution is to use some system default.

3. A third solution is to disallow multiple inheritance altogether


if name ambiguity occurs, instead forcing the user to change
the name of one of the functions in one of the supertypes.
1.9 MULTIPLE AND SELECTIVE INHERITANCE
Selective inheritance
 It
allows a subclass to inherit a limited number of properties from
the superclass.
 An EXCEPT clause may be used to list the functions in a supertype
that are not to be inherited by the subtype.
END OF CHAPTER ONE

You might also like