0% found this document useful (0 votes)
20 views22 pages

Adbchapter1 240227092312 A1eac3d7

The document discusses object-oriented concepts including object identity, encapsulation, and persistence. It covers topics like unique object identifiers, type constructors, defining object behavior through methods, and making objects persistent by storing them in a database beyond the lifetime of a program.

Uploaded by

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

Adbchapter1 240227092312 A1eac3d7

The document discusses object-oriented concepts including object identity, encapsulation, and persistence. It covers topics like unique object identifiers, type constructors, defining object behavior through methods, and making objects persistent by storing them in a database beyond the lifetime of a program.

Uploaded by

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

Chapter 1

Concepts for Object Oriented


Databases
By: Melaku Y
Chapter Outline
1. Overview of O-O Concepts
2. O-O Identity, Object Structure and Type
Constructors
3. Encapsulation of Operations, Methods and
Persistence
4. Type and Class Hierarchies and Inheritance

2
Introduction
• Data model is used to describe the structure of the database
• Traditional Data Models:
 Hierarchical (1960)
 Network (since mid-60’s)
 Entity-relationship Model
 Relational (since 1970 and commercially since 1982)
• Object Oriented (OO) Data Models since mid-90’s
• Reasons for creation of Object Oriented Databases
 Need for more complex applications
• Give the designer to specify both the structure of complex objects
and the operations
 Increased use of object-oriented programming languages
• Difficult to integrate with traditional database
 Need for additional data modeling features 3
1.1 Overview of Object-Oriented Concepts(1)
• As commercial object DBMSs became available, the need for a
standard model and language was recognized.
• Main Claim: OO databases try to maintain a direct correspondence
between:
 real-world and database objects so that objects do not lose their
integrity and identity and can easily be identified and operated upon
• 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. (Simula
1960s)
• Object: has two components:
 state (value) and behavior (operations)
Similar to program variable in programming language, except that it
will typically have a complex data structure as well as specific
operations defined by the programmer 4
Overview of Object-Oriented Concepts (2)
• In OO databases,
 objects may have an object structure of arbitrary complexity in order to
contain all of the necessary information that describes the object.
• In contrast, 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.
• Persistent vs transient object
 Transient object: exist only during program execution
 Persistent object: exist beyond program termination
 Stored by OO databases permanently in secondary storage
 Allow the sharing objects among multiple programs and applications.
 What needed: indexing and concurrency(DBMS Features)
5
Overview of Object-Oriented Concepts (3)

• The internal structure of an object in OOPLs


 includes the specification of instance variables, which hold the
values that define the internal state of the object.
• An instance variable is similar to the concept of an attribute,
 except that instance variables may be encapsulated within the
object and thus are not necessarily visible to external users
• Some OO models insist that
 all operations a user can apply to an object must be predefined.
This forces a complete encapsulation of objects.
 Issues: users required to know attribute name to retrieve specific
objects and any simple retrieval requires a predefined operation

6
Overview of Object-Oriented Concepts (4)

• 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.
 This 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

7
Overview of Object-Oriented Concepts (5)

• Type and Class hierarchies and Inheritance


 permits specification of new types or classes that inherit much of their
structure and/or operations from previously defined types or classes.
 this makes it easier to develop the data types of a system incrementally
and to reuse existing type definitions when creating new types of
objects.
 Operator overloading(operator polymorphism)
 refers to an operation’s ability to be applied to different types of objects
 in such a situation, an operation name may refer to several distinct
implementations, depending on the type of object it is applied to.

8
1.2 Object Identity, Object Structure, and Type
Constructors (1)
• Unique Identity:
 an OO database system provides a unique identity to each independent
object stored in the database.
 this unique identity is typically implemented via a unique, system-
generated object identifier(OID)
 the main property of OID
 immutable (should not change). this preserves the identity of the real-
world object being represented.
 used only once, even if an object is removed from the database, its OID
should not be assigned to another object
 Object may given one or more names meaningful to the user
identifies a single object within a database.
intended to act as ‘root’ objects that provide entry points into the
database. 9
Object Identity, Object Structure, and Type
Constructors (3)
• Type Constructors:
 In ODBs, a complex type may be constructed from other types by
nesting of type constructors.
• The three most basic constructors are:
 atom (basic built-in data types)
 tuple (compound or composite type)
• struct Name<FirstName: string, MiddleInitial: char, LastName:
string>
• struct CollegeDegree<Major: string, Degree: string, Year: date>
 collection (multivalued) => set, array, list, bag, dictionary
 The atom constructor is used to represent all basic atomic values
 integers, real numbers, character strings, Booleans, other
10
Object Identity, Object Structure, and Type
Constructors (4)
• Tuple constructor
 create structured values and objects of the form <a1:i1, a2:i2, … ,
an:in>
• Set constructor
 create objects or literals that are a set of distinct elements {i1, i2, … ,
in}, all of the same type
• Bag constructor
 Same as set but elements need not be distinct
• List constructor
 create an ordered list [i1, i2, … , in]
 Array constructor
 create a single-dimensional array of elements of the same type
 Dictionary constructor
 creates a collection of key-value pairs (K, V) 11
Object Identity, Object Structure, and Type
Constructors (5)

12
1.3 Encapsulation of Operations, Persistence of
Objects(1)
• 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 traditional database models and systems this concept was not
applied
 since it is customary to make the structure of database objects
visible to users and external programs
The relation and its attributes can be accessed using generic
operations.
 The concept of encapsulation means that
 Object contains both data structure and the set of operations used to
manipulate it.
13
1.3 Encapsulation of Operations,
Methods, and Persistence (2)
• The concept of information hiding means that
 external aspects of an object is separated from its internal details,
which are hidden from the outside world.
 The external users of the object are only made aware of the
interface (signature) of the operation
• Specifying Object Behavior via Class Operations (methods):
 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.
 In general, the implementation of an operation can be specified in a
general-purpose programming language that provides flexibility
and power in defining the operations
14
Encapsulation of Operations, Methods, and
Persistence (4)
 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).
 An operation is typically applied to an object by using the
dot notation.

15
16
Encapsulation of Operations, Methods, and
Persistence (6)
• Specifying Object Persistence via Naming and Reachability:
 Transient objects
• exist in the executing program and disappear when program
terminates.
 Persistent objects
• stored in the database and persist after program termination.
• Mechanisms to make an object persistent
 Naming Mechanism:
• name can be given to an object via a specific statement or operation in the
program
• the named objects are used as entry points to the database through which
users and applications can start their database access
 Reachability Mechanism:
• Make 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 object graph lead from object A to object B.
17
Encapsulation of Operations, Methods, and
Persistence (6)

18
1.4 Type and Class Hierarchies and Inheritance (1)
• Type (class) Hierarchy
 A type is defined by
 assigning type name and defining attributes (instance variables) and
operations (methods).
 has a type name and a list of visible (public) functions
• Specifications: TYPE_NAME: function, function, . . . , function
 Example:
• PERSON: Name, Address, Birthdate, Age, SSN
• Subtype:
 When the designer or user must create a new type
 that is similar but not identical to an already defined type
 inherits all the functions of supertype

19
Type and Class Hierarchies and Inheritance (3)

• Example (1):
 PERSON: Name, Address, Birthdate, Age, SSN
 EMPLOYEE: Name, Address, Birthdate, Age, SSN, Salary,
HireDate, Seniority
 STUDENT: Name, Address, Birthdate, Age, SSN, Major, GPA
• OR:
 EMPLOYEE subtype-of PERSON: Salary, HireDate, Seniority
 STUDENT subtype-of PERSON: Major, GPA

20
Type and Class Hierarchies and Inheritance (4)

• Example (2):
 GEOMETRY_OBJECT: Shape, Area, ReferencePoint

 RECTANGLE subtype-of GEOMETRY_OBJECT: Width, Height


 TRIANGLE subtype-of GEOMETRY_OBJECT: Side1, Side2, Angle
 CIRCLE subtype-of GEOMETRY_OBJECT: Radius

21
Thank you

22

You might also like