Chapter One-Object Oriented Database Cocepts
Chapter One-Object Oriented Database Cocepts
Chapter One:
Object-Oriented Data
Object-Oriented Concepts
Object Identity
Object Structure
Type Constructors
Encapsulation
• What is database?
• Objects are self-contained units that contain both data and the operations or
methods that can be performed on that data. It helps in efficient representation
and management of complex data structures and relationships.
• They are also well suited for applications that require the integration of
different data types and sources, such as multimedia data or data from
multiple sources.
9
Cont’d…
Objects
Inheritance
Methods
Attributes
Encapsulation
Polymorphism
Identity
Transactions
Object Structure refers to the way in which data and methods are
organized within an object. It encompasses the attributes (data) and
methods (functions) that define the behavior of the object.
The organization of data and methods within an object is
fundamental to the encapsulation principle of object-oriented
programming.
6
4
Cont’d…
6
6
…continued
• 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
[i1,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
6
7
• 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.
…cont
Encapsulation of Operations, Methods, and Persistence
7
1
Group Discussion
Discuss for 20 min and report the discussion
• E-R diagram, Normalization, UML ,Database
Design
• What is the different between oodb and relational
database?
• What does encapsulation, inheritance and
polymorphism mean?
• What is object identity (oid) mean and immutable
mean?
• What are the types of structure ?
7
2
Specifying Object Persistence via Naming
and Reachability.
• Transient objects exist in the executing
program and disappear once the program
terminates.
• Persistent objects are stored in the
database and persist after program
termination.
• The typical mechanisms for making an object
persistent are naming and reachability.
7
3
Cont’d…
• The naming mechanism involves giving an object a
unique persistent name within a particular database.
• This persistent object name can be given via a specific
statement or operation in the program.
• The named persistent objects are used as entry points to
the database through which users and applications can
start their database access.
• 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.
7
4
Type Hierarchies and Inheritance
• Another main characteristic of ODBs is that they allow type
hierarchies and inheritance.
• We use a simple OO model in this section a model in which
attributes and operations are treated uniformly since both
attributes and operations can be inherited.
• Inheritance allows the definition of new types based on other
predefined types, leading to a type (or class) hierarchy.
7
6
Cont’d…
8
0
…continued
• A type in its simplest form has a type name and a
list of visible (public) functions. When specifying
a type in this section, we use the following format,
which does not specify arguments of functions, to
simplify the discussion:
TYPE_NAME: function, function, ..., function
• For example, a type that describes characteristics
of a PERSON may be defined as follows:
PERSON: Name, Address, Birth_date, Age, Ssn
8
1
…continued
• The concept of subtype is useful when the designer or user must
create a new type that is similar but not identical to an already
defined type. The subtype then inherits all the functions of the
predefined type, which is referred to as the supertype.
• For example, suppose that we want to define two new types
EMPLOYEE and STUDENT as follows:
EMPLOYEE: Name, Address, Birth_date, Age, Ssn, Salary,
Hire_date, Seniority
STUDENT: Name, Address, Birth_date, Age, Ssn, Major, Gpa
• Since both STUDENT and EMPLOYEE include all the
functions defined for PERSON plus some additional functions
of their own, we can declare them to be subtypes of PERSON.
8
2
…continued
8
3
Multiple Inheritance and Selective Inheritance
8
4
…continued
• One problem that can occur with multiple inheritance is that the
supertypes from which the subtype inherits may have distinct
functions of the same name, creating an ambiguity.
• For example, both MANAGER and ENGINEER may have a
function called Salary. If the Salary function is implemented by
different methods in the MANAGER and ENGINEER supertypes,
an ambiguity exists as to which of the two is inherited by the
subtype ENGINEERING_MANAGER.
8
5
Cont’d…
8
7
Cont’d…
• Selective inheritance occurs when a subtype
inherits only some of the functions of a
supertype.
• Other functions are not inherited. In this case,
an EXCEPT clause may be used to list the
functions in a supertype that are not to be
inherited by the subtype.
8
8
Polymorphism of Operations (Operator
Overloading).
• This concept allows the same operator name or symbol to
be bound to two or more different implementations of the
operator, depending on the type of objects to which the
operator is applied.
• example, the function Area is declared for all objects of type
GEOMETRY_OBJECT. However, the implementation of the
method for Area may differ for each subtype of
GEOMETRY_OBJECT. One possibility is to have a general
implementation for calculating the area of a generalized
GEOMETRY_OBJECT
8
9
Cont’d…