You are on page 1of 33

CoSc 266

Advanced Database
Management System

Instructor: Shewakena G.
Outline
● Overview
● Object Identity
● Object Structure
● Type Constructors
Chapter One ● Encapsulation of
Operation
● Methods & Persistence
Object-oriented ● Type Hierarchies &
Inheritance
Complex Objects
Database ●
● Polymorphism
● Multiple & Selective
Inheritance
● Data
■ Data is known facts that can be
recorded and that have implicit
meaning.
Introduction ● Database
○ A collection of related data with an implicit meaning
○ A database has the following implicit properties:
■ represents some aspect of the real world,
sometimes called the mini-world
■ a logically coherent collection of data with some
inherent meaning.
■ designed, built, and populated with data for a
specific purpose.
&
a n i ze d ■ It has an intended group of users and some
l org
Wel logical preconceived applications in which these users
are interested.
● DBMS
○ A database management system (DBMS)
Introduction DBMS is a collection of programs that enables
users to create and maintain a database.
○ There are two operation(Fasilitate) in
DBMS:
■ DDL: allows users to specify the data types and
structures and the constraints on the data to be stored in
the database.

■ DML: Having a central repository for all data and data


descriptions allows the DML to provide a general inquiry
facility to this data, called a query language.

○ Microsoft SQL, Oracle , MySQL, DB2,


Types of Database
● File based system
○ Adequate for small business
○ Drawback
■ Separation and Isolation of Data
■ Duplication of Data
Introduction ■ Data Dependency
■ Incomputable file format
Data Recording Approach
■ Difficulty in accessing and querying data since a new
program has to be written to carry out each new task.

● 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)
Advantages of
DBMSs
Disadvantages DBMSs
What are the 4 Basic types
of databases?
Introduction 1) Hierarchical/ Network
Types of Database databases.
2) Relational databases.
3) NoSQL databases.
4) Object-oriented databases.
Hierarchical/Network Database Model

Introduction ► It is the type of database that stores data in the form

Types of Database of parent-children relationship nodes.


► Suitable for data which are related

► Hierarchically start by defined tree of data node

► Data get stored in the form of records that are


connected via links.
► Each child record in the tree will contain only
one parent.
► On the other hand, each parent record can have
multiple child records.
Introduction Relational Database
Types of Database Con…  stores data in the form of rows(tuple) and
columns(attributes), and together forms a
table(relation).
 uses SQL for storing, manipulating, as well
as maintaining the data.
 Each table in the database carries a key that
makes the data unique from others.
 Examples of Relational databases are
MySQL, Microsoft SQL Server, Oracle, etc.
 Properties of Relational Database
Rational DB Con…  commonly known properties of a
relational model known as ACID.
● A means Atomicity: This ensures the data operation
will complete either with success or with failure.

○ For example, a transaction will either be committed or


will abort.
● C means Consistency: If we perform any operation
over the data, its value before and after the operation
should be preserved
● I means Isolation: There can be concurrent users for
accessing data at the same time from the database.
Thus, isolation between the data should remain
isolated.
● D means Durability: It ensures that once it completes
the operation and commits the data, data changes
should remain permanent.
Introduction NoSQL databases
Types of Database Con…  Non-SQL/Not Only SQL is a type of
database that is used for storing a wide range
of data sets.
 It is not a relational database as it stores data
not only in tabular form but in several
different ways.
 NoSQL presented a wide variety of database
technologies in response to the demands.
 non-tabular databases and store data
differently than relational tables.
Four types of NoSQL database
● Traditional data models and systems,
○ have been quite successful for traditional
business database applications.
○ However, they have certain shortcomings
when more complex database
applications must be designed and
Object Oriented Database implemented
○ for example, databases for engineering
Why Object Oriented database? 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.
○ Vast increase in the use of object-oriented
programming languages for developing
software applications.
Object-Oriented ● Model that an OODBMS
must, at a minimum, satisfy:
DBMSs 1) it must provide database
functionality;
2) it must support object
identity;
3) it must provide
encapsulation;
4) it must support objects with
complex state.
 object-orientation = abstract
data types + inheritance +
object identity;
 OODBMS = object-
orientation + database
capabilities.
Origins of the object-oriented data model
♦Abstraction:
Object-oriented programming ♦ is the process of hiding the internal details of an application
from the outer world.

(OOP) concepts ♦Its main goal is to handle complexity by hiding


unnecessary details from the user.
♦Encapsulation:
♦hides the implementation details from the end-
users and displays only the needed descriptions.
♦Its benefit is that it protects the object from
unwanted interference and human error.
♦Inheritance:
♦mechanism in which one object acquires all the
properties and behaviors of a parent object.
♦It is defined as the method of creating new classes
from existing classes.
♦Polymorphism
♦you can access objects of different types through
the same interface.
♦is the ability of an object to take on many forms.
● 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


Object 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)
● 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.
Characteristics of ● Structure of object

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.
● Transient object
○ In OOPL, objects which are present only at the time
of execution are called as transient object.
● Persistent objects
○ An object which exists even after the program is
completely executed (or terminated)
● 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
Object 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.
● 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
Object Structure ○ 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.
● 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.
Equal vs. Identical
● Two object are said to have equal values if
Objects 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.
Encapsulation
○ main characteristics of OO languages and systems
○ 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.
Encapsulation of ■ For example, selecting, inserting,
deleting, and modifying tuples are
Operations generic and may be applied to any
relation in the database

○ Specifying Object Behavior via Class Operations:


○ behavior are defined in object is 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).
● 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
Encapsulation in OODBs object, which includes the operation name and the
parameters.
● The object then executes the method for that operation.
● Some operations used to create (insert) or destroy
(delete) objects or update the object state or retrieve
parts of the object state.
● 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
Adding operations to definitions of Employee
Encapsulation in and Department:

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),
Encapsulation in OODBs 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
● Persistence in databases refers to the ways in
which processes or objects can continue on, or
remain, even when systems are shut down.
○ When a created process needs persistence, non-
volatile storage, including a hard disk, is used
instead of volatile memory like RAM.
● Specifying Object Persistence via
○ Naming and
Methods and Persistence ○ Reachability
Naming
○ The naming mechanism involves giving an object
a unique persistent name within a particular
database.
○ It is 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.
Creating persistent objects by naming and
reachability

Methods and
Persistence
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
Type Hierarchies and ○ 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
Inheritance (instance variables) and operations (methods) for the type are
together called functions
○ TYPE_NAME: function, function, . . . , function
○ 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)
Type (class) Hierarchy
Example (1):
PERSON: Name, Address, Birthdate, Age, SSN

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


Type Hierarchies and Hire_Date, Seniority

Inheritance 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

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.
● 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 ● Polymorphism also called operator overloading


● Polymorphism can be applied using method overloading or
method overriding.
Example 1
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; }
Example 1- Overloading
GEOMETRY_OBJECT type: Shape, Area, ReferencePoint

RECTANGLE subtype-of GEOMETRY_OBJECT

(Shape=‘rectangle’): Width, Height

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


Side1, Side2, Angle

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


Multiple inheritance
Multiple inheritance refer that the subclass inherit from more than one
superclasses.
Example:

Manager salesStaff
Multiple and Selective
inheritance 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

There are several techniques for dealing with ambiguity in multiple


inheritance.
● check for ambiguity when the subtype is created, and to let the
user explicitly choose which function is to be inherited at this
time.
● A second solution is to use some system default.
● disallow multiple inheritance altogether
Selective inheritance
○ It allows a subclass to inherit a limited
number of properties from the superclass.
Multiple and Selective ○ An EXCEPT clause may be used to list the
functions in a supertype that are not to be
inheritance inherited by the subtype.
End of Chapter
One

You might also like