Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
411 views

Advanced Database Chapter One

This chapter discusses key concepts for object-oriented databases including object identity, structure, type constructors, and inheritance. Object identity provides each object with a unique identifier. An object's structure includes its properties, methods, and messages. Type constructors define complex object types by nesting basic types like atoms, tuples, and collections. Inheritance allows classes to inherit attributes and methods from parent classes. Examples demonstrate how these concepts map relational database structures to an object-oriented model.

Uploaded by

Ani Nimoona Dha
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
411 views

Advanced Database Chapter One

This chapter discusses key concepts for object-oriented databases including object identity, structure, type constructors, and inheritance. Object identity provides each object with a unique identifier. An object's structure includes its properties, methods, and messages. Type constructors define complex object types by nesting basic types like atoms, tuples, and collections. Inheritance allows classes to inherit attributes and methods from parent classes. Examples demonstrate how these concepts map relational database structures to an object-oriented model.

Uploaded by

Ani Nimoona Dha
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 60

CoSc2072 : Advanced Database

systems
Chapter One:
Concepts for Object-Oriented
Databases

Department of Computer Science


College of Engineering and
Technology
Chapter Contents

1.1.Overview of Object-Oriented Concepts


1.2.Object Identity, Object Structure, and
Type Constructors
1.3.Encapsulation of Operations, Methods,
and Persistence
1.4.Type Hierarchies and Inheritance
Overview of Object-Oriented Concepts

 The term object-oriented (OO) has its origins


in OO Programming language.
 The basic Object-Oriented programming
concepts includes:
Inheritance
Polymorphism
Abstraction
Encapsulation
Inheritance
 One of the most important aspects of OOP
 Inheritance is the procedure in which one
class inherits the attributes and methods of
another class.
 The key to understanding inheritance is that
it provides code reusability.
Q. Can the child class have its own properties
and methods?
Polymorphism

 It is the ability of an object to perform


different actions (or, exhibit different
behaviour) based on the context.
Abstraction
 Abstraction is a process of hiding the
implementation details from the user, only
the functionality will be provided to the user.
 It means the user will have the information
on what the object does instead of how it
does.
 In java, abstraction is achieved using Abstract
classes and interface.
Encapsulation

 The capability to store related information,


whether data or methods, together with an
object.
 It describes the idea of bundling data and
methods that work on that data within one
unit.
 Both the object structure and the operations
that can be applied to individual objects are
included in the class/type definitions.
Object Oriented Database
What is objects?

 An object, in Object-Oriented programming


(OOP), is an abstract data type created by a
developer.
 Has two components, state (value) and
behaviour (operation)
 It can include multiple properties and
methods and may even contain other Object
Eg. Class in java
What is objects?...

 Example: user account created for website.


The object might defined as class
userAccount and contain attributes such as
first name, last name, email address,
password, age… instead of recreating these
properties each time a new user account is
created, a web script can simply instantiate
a userAccount object.
Object Oriented Database (1)

 It is a database that is based on object-


oriented programming(OOP).
 Data is represented and stored in the
form of objects.
 An object oriented database is organized
around objects rather than actions and
data rather than logic.
Object Oriented Database (2)

 A key feature of object databases is the power


they give the designer to specify both the
structure of complex objects and the
operations that can be applied to these
objects.
 Object oriented databases are designed so
they can be directly—or seamlessly—
integrated with software that is developed
using object-oriented programming
languages.
Object Oriented Database (3)
 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.
Object Oriented Database (4)

 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 Oriented Database (5)
 OO databases store persistent objects
permanently in secondary storage and allow
the sharing of these objects among multiple
programs and applications.
 This requires the incorporation of other well-
known features of database management
systems such as indexing mechanism to
efficiently locate the objects, concurrency
control to allow the object sharing among
concurrent programs, and recovery from
failures.
Object Oriented Database (6)
 Some OO models insist that all operations a
user can apply to an object must be
predefined. This forces a complete
encapsulation of objects.
 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.
Object Oriented Database (7)
 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.
Object Oriented Database (8)

 Reasons for creation of Object Oriented


Databases:
 Need for more complex applications
 Need for additional data modelling
features.
 Increased
use of object-oriented
programming language.
What is the Difference between
Object in OOPL and OODB?
Objects in OOPL

 Objects in an OOPL exist only during


program execution.
 They are called transient objects.
Objects in OODB
 An OO database can extend the existence
of objects so that they are stored
permanently in a database.
 Object is persistent.
 Object exists beyond program termination
and can be retrieved later and shared by
other program.
Object Identity, Object
Structure and Type Constructors
Object Identity (1)
 Object identity is a property of data that is
created in the context of an object data
model, where an object is assigned a unique
internal object identifier.
 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, or OID
Object Identity (2)
 Object Identifier is used to define
associations between objects and to support
retrieval and comparison of object-oriented
data based on the internal identifier rather
than the attribute values of an object.
 OID is immutable, meaning that the value of
the object identifier cannot change over
lifetime of the object.
 The state, on the other hand, is mutable,
representing the attributes that define
associations among objects.
Object Structure (1)

 Thestructure of an object refers to the


properties that an object is made up of.
 Object structure is further composed of
three types of components. Messages,
Methods and Variables.
 A message provides an interface or acts
as a communication medium between
an object and the outside world.
Object Structure (2)

 When a message is passed then the body of


code that is executed is known as a Method.
 Every time when a method is executed, it
returns a value as output.
 A variable stores the data of an object.
 The data stored in the variable makes the
object distinguishable from one another.
Type Constructors (1)

 In ODBs, a complex type may be


constructed from other types by nesting
of type constructors.
 The three most basic constructors are
 Atom
 struct (or tuple) and
 Collection
Type Constructors (2)
 Atom Constructor:
 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.
 These basic data types are called single-
valued or atomic types, since each value
of the type is considered an atomic
(indivisible) single value.
Type Constructors (3)
 Struct (or tuple) constructor:
 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.
 Itis type generator, because many
different structured types can be created.
Type Constructors (3)…

 For example, two different structured


types that can be created are:
struct Name<FirstName: string,
MiddleInitial: char, LastName: string>,
and
struct CollegeDegree<Major: string,
Degree: string, Year: date>.
Type Constructors (4)
 Collection (Multivalued) Constructor:
 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.
 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.
Type Constructors (5)
Object Identity, Object Structure,
and Type Constructors Examples (1)
 Example 1
 One possible relational database state corresponding to
COMPANY schema
Object Identity, Object Structure,
and Type Constructors Examples (2)
 Example 1 (contd.):
Object Identity, Object Structure,
and Type Constructors Examples (3)

 Example 1 (contd.)
Object Identity, Object Structure,
and Type Constructors Examples (4)
 Example 1 (contd.)
 We use i1, i2, i3, . . . to stand for unique system-
generated object identifiers. Consider the
following objects:
o = (i1, atom, ‘Houston’)
1

o = (i2, atom, ‘Bellaire’)


2

o = (i3, atom, ‘Sugarland’)


3

o = (i4, atom, 5)
4

o = (i5, atom, ‘Research’)


5

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


6

o = (i7, set, {i1, i2, i3})


7
Object Identity, Object Structure,
and Type Constructors Examples (5)
 Example 1(contd.)
o8 = (i8, tuple, <dname:i5, dnumber:i4, mgr:i9,
locations:i7, employees:i10, projects:i11>)
o9= (i9, tuple, <manager:i1,
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 Identity, Object Structure,
and Type Constructors Examples (6)
 Example 1 (contd.)
 The first six objects listed in this example
represent atomic values.
 Object seven is a set-valued object that
represents the set of locations for
department 5; the set refers to the atomic
objects with values {‘Houston’, ‘Bellaire’,
‘Sugarland’}.
 Object 8 is a tuple-valued object that
represents department 5 itself, and has the
attributes DNAME, DNUMBER, MGR,
LOCATIONS, and so on.
Object Identity, Object Structure,
and Type Constructors Examples (7)
 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)
 o = (i , atom, 20)
Object Identity, Object Structure,
and Type Constructors Examples (8)
 Example 2 (contd.):
 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.
 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 o4 and o5 are
identical, the actual objects o4 and o5 are
equal but not identical, because they have
distinct OIDs.
Graph Representation
Encapsulation of Operations, Methods
and Persistence
Encapsulation of Operations
(1)
 One of the main characteristics of OO languages
and systems
 Related to the concepts of abstract data types and
information hiding in programming languages
 The concept of encapsulation is applied to
database objects in ODBs by defining the
behaviour of a type of object based on the
operations that can be externally applied to
objects of that type.
Encapsulation of Operations
(2)
 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.
 The external users of the object are only made
aware of the interface of the operations, which
defines the name and arguments (parameters) of
each operation.
Encapsulation of Operations
(3)
 Some operations may be used to:
 create (insert)
 destroy (delete) objects
 update the object state
 retrieve parts of the object state
 apply some calculations.
Encapsulation of Operations (4)
 For database applications, the requirement that all
objects be completely encapsulated is too stringent
(must be obeyed).
 One way to relax this requirement is to divide the
structure of an object into visible and hidden
attributes (instance variables).
 Visible attributes can be seen by and are directly
accessible to the database users and programmers
via the query language.
 The hidden attributes of an object are completely
encapsulated and can be accessed only through
predefined operations.
Encapsulation of Operations (5)
Encapsulation of Operations
(6)
 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.
 The dot notation is also used to refer to attributes of
an object—for example, by writing d.Dnumber or
d.Mgr_Start_date.
Persistence (1)

 The typical mechanisms for making an object


persistent are naming and reachability.
 Naming Mechanism:
 giving an object a unique persistent name
within a particular database through which it
can be retrieved by this and other programs.
 this persistent object name can be given via a
specific statement or operation in the program.
Persistence (2)

 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.
Persistence (3)
Persistence (4)
 From above example, we can define a class
DEPARTMENT_SET whose objects are of type
set(DEPARTMENT).
 We can create an object of type
DEPARTMENT_SET, and give it a persistent name
ALL_DEPARTMENTS.
 Any DEPARTMENT object that is added to the set
of ALL_DEPARTMENTS by using the add_dept
operation becomes persistent by virtue of its being
reachable from ALL_DEPARTMENTS.
Type (Class) Hierarchies and Inheritance
Type (Class) Hierarchies and
Inheritance (1)
 Another main characteristic of ODBs is that they
allow type hierarchies and inheritance.
 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.
 In the simplified model we use in this section, the
attributes and operations are together called functions.
TYPE_NAME: function, function, . . . , function
 Example.
PERSON: Name, Address, Birthdate, Age, SSN
Type (Class) Hierarchies and
Inheritance (2)
 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.
Type (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
Type (Class) Hierarchies and
Inheritance (4)
Example (2):
 Consider a type that describes objects in plane geometry,
which may be defined as follows:
 GEOMETRY_OBJECT: 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
Type (Class) Hierarchies and
Inheritance (5)
 Example (2) (contd.):
 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
Type (Class) Hierarchies and
Inheritance (6)
Extents
 In most ODBs, an extent is defined to store the
collection of persistent objects for each type or
subtype.
 Persistent Collection:
 This holds a collection of objects that is stored
permanently in the database and hence can be
accessed and shared by multiple programs
 Transient Collection:
 This exists temporarily during the execution of a
program but is not kept when the program
terminates
Thank U!

You might also like