0% found this document useful (0 votes)
4 views

Advanced Database Chapter Four & Five

database

Uploaded by

princefamily877
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Advanced Database Chapter Four & Five

database

Uploaded by

princefamily877
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

CHAPTER FOUR

Object Oriented Database

1 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Object Based Database Systems
 Traditional database applications consist of data-processing tasks, such as banking

and payroll management, with relatively simple data types that are well suited to
the relational data model.

 As database systems were applied to a wider range of applications, such as

computer-aided design and geographical information systems, limitations imposed


by the relational model emerged as an obstacle.

 The solution was the introduction of object-based databases, which allow one to

deal with complex data types.

2 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Object Based Database Systems
 Relational models were limiting in the kind of data that could be held, the rigidity

of the structure, and the lack of support for new data types such as graphics, xml,
2D and 3D data.

 In the 1980s With the advent of Object Oriented methodologies and languages,

integration of database capabilities with object oriented programming language


provided a unified programming environment.

 This led to the development of OODB and OODBMS where objects are stored in

databases rather than data such as integers, strings or real numbers.

3 Prepared BY: Abebe SH. (MSc.) 1/16/2024


What is Object oriented database?
 An object-oriented database is a type of database management system
(DBMS) that stores data in the form of objects, rather than in tables like
traditional relational databases.
 In an object-oriented database, data is represented as objects that have
attributes (data fields) and methods (functions) that can be used to manipulate
the data.
 However, object-oriented databases also have some disadvantages, including
a lack of standardization and a steep learning curve for developers who are
not familiar with object-oriented programming concepts.
4 Prepared BY: Abebe SH. (MSc.) 1/16/2024
What is Object oriented database?

5 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Object Based Database Systems
 The type of a database is decided by the data model used in the design of the

database.

 Data models are data structures which describe how data are represented and

accessed. Data models must be simple and intuitive to enable applications

 The major types of data models in the history of Databases are

o Hierarchical model

o Network Model

o Relational Model

o Object oriented Model


6 Prepared BY: Abebe SH. (MSc.) 1/16/2024
Object Based Database Systems
An object-oriented database (OOD) is a database system that can work with

complex data objects.

In object-oriented programming, everything is an object, and many objects

are quite complex, having different properties and methods.

Object database management systems extend the object programming

language with transparently persistent data, concurrency control, data


recovery, associative queries, and other database capabilities.

7 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Object Relational DBMS
 An object-relational database (ORD) is a database management system (DBMS)

that's composed of both a relational database (RDBMS) and an object-oriented


database (OODBMS).

 ORD supports the basic components of any object-oriented database model in its

schemas and the query language used, such as objects, classes and inheritance.

 An object-relational database may also be known as an object relational database

management systems (ORDBMS).

8 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Reasons for using ORDBMS over RDBMS
 Storage requirements of newer applications - Conventional RDBMSs cannot
handle the data like engineering designs, scientific experiments, GIS, and
multimedia data.
 Handling of data stored for newer applications – retrieve and manipulate data
stored for newer applications like other data with RDBMS functionalities.
 Ability to define user defined data types – to handle new type of data as and
when required.
 Reusability nature of objects – One of the main features of using objects, and
methods.
 Database extensibility – easy addition of data types and operations
Prepared BY: Abebe SH. (MSc.)
9 1/16/2024
Object-Oriented Model Vs Relational Model

10 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Object-Oriented Model Vs Relational Model

11 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Fundamentals of object oriented database

12 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Fundamentals of object oriented database

13 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Fundamentals of object oriented database

14 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Object Definition Language
 Object Definition Language (ODL) is a language used to define objects in
an object-oriented database.
 ODL provides a set of syntax and rules for defining the structure and
behavior of objects, including their attributes, methods, and relationships
with other objects.
 ODL defines three components of the object oriented data model:
 Abstraction
 Inheritance
 Encapsulation
15 Prepared BY: Abebe SH. (MSc.) 1/16/2024
Data Abstraction
 Data Abstraction is a process of hiding unwanted or irrelevant details from
the end user.
 It provides a different view and helps in achieving data independence
which is used to enhance the security of data.
 The database systems consist of complicated data structures and relations.
 There are three levels of abstraction
 Physical level
 Logical level
 View level
16 Prepared BY: Abebe SH. (MSc.) 1/16/2024
Encapsulation
 Encapsulation in object oriented means an object contains both the data
structures and the methods to manipulate the data structures.
 The data structures are internal to the object and are only accessed by other
objects through the public methods.
 Encapsulation ensures that changes in the internal data structure of an object
does not affect other objects provided the public methods remains the same.
 Encapsulation provides a form of data independence.

17 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Inheritance
Inheritance is an important feature of Generalization and Specialization.

It allows lower-level entities to inherit the attributes of higher-level entities.

For example, the attributes of a Person class such as name, age, and gender

can be inherited by lower-level entities such as Student or Teacher.

18 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Complex Data Types
 Traditional database applications have conceptually simple data types.
 The basic data items are records that are fairly small and whose fields are
atomic.
 A complex data type is usually a composite of other existing data types.
 For example, you might create a complex data type whose components
include built-in types, opaque types, distinct types, or other complex types.]
 With complex type systems we can represent E-R model concepts, such as
composite attributes, multivalued attributes, generalization, and specialization
directly, without a complex translation to the relational model.
19 Prepared BY: Abebe SH. (MSc.) 1/16/2024
Structured Types and Inheritance in SQL
 Structured types allow composite attributes of E-R designs to be represented directly.
 For instance, we can define the following structured type to represent a composite
attribute name and address with component attribute .

20 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Structured Types and Inheritance in SQL
 Constructor functions are used to create values of structured types. A function with the

same name as a structured type is a constructor function for the structured type.

 For instance, we could declare a constructor for the type Name like this:

 create function Name (firstname varchar(20), lastname varchar(20))

returns Name

begin

set self.firstname = firstname;

set self.lastname = lastname;

End;

21 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Implementing O-R Features
 Object-relational database systems are basically extensions of existing relational

database systems.

 Changes are clearly required at many levels of the database system.

 However, to minimize changes to the storage-system code (relation storage,

indices, etc.), the complex data types supported by object-relational systems can
be translated to the simpler type system of relational databases.

22 Prepared BY: Abebe SH. (MSc.) 1/16/2024


23 Prepared BY: Abebe SH. (MSc.) 1/16/2024
CHAPTER FIVE

Distributed Database system

24 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Distributed database Systems
 A distributed database is a database that consists of two or more files located

in different sites either on the same network or on entirely different


networks.

 Portions of the database are stored in multiple physical locations and

processing is distributed among multiple database nodes.


What is the difference Between Centralized and Distributed Databases?

25 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Distributed Vs Centralized Databases
 Centralized Database  Distributed Database
– In a centralized database there is a single database – Distributed database is basically a type of
file at one location in the network. database which consists of multiple databases
that are connected with each other and are
– Multiple users can access this single database via spread across different physical locations
a computer network (LAN, WAN, etc.)
– The communication b/n databases at different
– This type of database is mainly used by physical location is thus done by a computer
institutions or organizations. network.

26 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Distributed database Systems
 A Distributed Database is a collection of multiple, logically interrelated databases
distributed over a computer network.
 Distributed DBMS is a software system that manages a distributed database while
making the distribution transparent to the user.
 The computers in a distributed system are referred to by a number of different
names, such as sites or nodes.
 The computers in a distributed system communicate with one another through
various communication media, such as high-speed private networks or the Internet.
 In distributed database there are two types of transactions
 Local Transaction:- is one that accesses data only from sites where the transaction
was initiated.
 Global Transaction:- is one that either accesses data in a site different from the
one at which the transaction was initiated, or accesses data in several different
sites.
27 Prepared BY: Abebe SH. (MSc.) 1/16/2024
Advantages of DDB Systems
 Increased reliability and availability
 Reliability is the measure of how long a machine performs its intended function, whereas

 Availability is the measure of the percentage of time a machine is operable. For example, a
machine may be available 90% of the time, but reliable only 75% of the time from a
performance standpoint.
 When the data and DBMS software are distributed over several sites, one site may fail
while other sites continue to operate.
 Only the data and software that exist at the failed site cannot be accessed.

 In a centralized system, failure at a single site makes the whole system unavailable to all
users.
 In a distributed database, some of the data may be unreachable, but users may still be able
to access other parts of the database.
28 Prepared BY: Abebe SH. (MSc.) 1/16/2024
Advantages of DDB Systems
 Improved performance:

 A distributed DBMS fragments the database by keeping the data closer to where it

is needed most.
 When a large database is distributed over multiple sites, smaller databases exist at

each site.
 As a result, local queries and transactions accessing data at a single site have

better performance because of the smaller local databases.


 In addition, each site has a smaller number of transactions executing than if all

transactions are submitted to a single centralized database.

29 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Advantages of DDB Systems
 Improved shareability and local autonomy

 The geographical distribution of an organization can be reflected in the distribution

of the data; users at one site can access data stored at other sites.
 Data can be placed at the site close to the users who normally use that data.

 In this way, users have local control of the data and they can consequently

establish and enforce local policies regarding the use of this data.
 A global database administrator (DBA) is responsible for the entire system.

 Generally, part of this responsibility is devolved to the local level, so that the local

DBA can manage the local DBMS

30 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Advantages of DDB Systems
 Modular Growth

 In a distributed environment, it is much easier to handle expansion. New sites can

be added to the network without affecting the operations of other sites.


 This flexibility allows an organization to expand relatively easily. Increasing

database size can usually be handled by adding processing and storage power to
the network.
 In a centralized DBMS, growth may entail changes to both hardware (the

procurement of a more powerful system) and software (the procurement of a more


powerful or more configurable DBMS).

31 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Disadvantages of DDB systems
 Cost

 The procurement and maintenance costs for a DDBMS to be higher than those for a
centralized DBMS.
 Distributed DBMS requires additional hardware to establish a network between sites.

 There are ongoing communication costs incurred with the use of this network.

 There are also additional labor costs to manage and maintain the local DBMSs and the
underlying network.
 Maintaining Data

 Managing, updating and taking in backups of data is easier in a centralized database


because there is only one database file.
 On the other hand, as there are multiple database files in a distributed database, it
32 Prepared BY: Abebe SH. (MSc.) 1/16/2024
requires time to synchronize data.
Disadvantages of DDB systems
 Database design more complex

 Besides the normal difficulties of designing a centralized database, the design

of a distributed database has to take account of fragmentation of data,


allocation of fragments to specific sites, and data replication.

33 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Types of DDB system
 Distributed database systems are classified in to two types. These are,

1. Homogeneous distributed database system


o In a homogeneous distributed database system, all sites have identical database
management system software, are aware of one another, and agree to cooperate in
processing users’ requests.
2. Heterogeneous distributed database system
o In a heterogeneous distributed database, different sites may use different schemas, and
different database-management system software.
o The sites may not be aware of one another, and they may provide only limited facilities for
cooperation in transaction processing.
o The differences in schemas are often a major problem for query processing, while the
divergence in software becomes a hindrance for processing transactions that access multiple

34
sites
Prepared BY: Abebe SH. (MSc.) 1/16/2024
Distributed Data Storage
 Consider a relation r that is to be stored in the database. There are two approaches to
storing this relation in the distributed database:
 Replication

– The system maintains several identical replicas (copies) of the relation, and stores each
replica at a different site.
– The alternative to replication is to store only one copy of relation r

 Fragmentation

– The system partitions the relation into several fragments, and stores each fragment at a
different site.
– Fragmentation and replication can be combined: A relation can be partitioned into several
fragments and there may be several replicas of each fragment.
Prepared BY: Abebe SH. (MSc.)
35 1/16/2024
Data Replication
 Replication is useful in improving the availability of data.

 The most extreme case is replication of the whole database at every site in the

distributed system, thus creating a fully replicated distributed database.

 This strategy consists of maintaining a complete copy of the database at each site.

– Therefore, locality of reference, reliability and availability, and performance

are maximized.
 However, storage costs and communication costs for updates are the most

expensive.

36 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Data fragmentation
 In a DDB, decisions must be made regarding which site should be used to store which
portions of the database.
 There are three rules that must be followed during fragmentation:
 Completeness:- If a relation instance R is decomposed into fragments R1, R2,...,Rn, each
data item that can be found in R must appear in at least one fragment.
 This rule is necessary to ensure that there is no loss of data during fragmentation.
 Reconstruction:- It must be possible to define a relational operation that will reconstruct
the relation R from the fragments.
 This rule ensures that functional dependencies are preserved
 Disjointness:- If a data item di appears in fragment Ri, then it should not appear in any
other fragment.
 Vertical fragmentation is the exception to this rule, where primary key attributes must
be repeated to allow reconstruction.
 This rule ensures minimal data redundancy.
Prepared BY: Abebe SH. (MSc.) 1/16/2024
37
Types of fragmentation
 There are two main types of fragmentation:
 Horizontal fragmentation:- Horizontal fragments are subsets of tuples and
 Vertical Fragmentation:- vertical fragments are subsets of attributes

38 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Horizontal Fragmentation
 A horizontal fragment of a relation is a subset of the tuples in that relation.

 In horizontal fragmentation, a relation r is partitioned into a number of subsets, r1,

r2,...,rn.

 Each tuple of relation r must belong to at least one of the fragments, so that the original

relation can be reconstructed, if needed.

 The tuples that belong to the horizontal fragment are specified by a condition on one or

more attributes of the relation. Often, only a single attribute is involved.

 In general, a horizontal fragment can be defined as a selection on the global relation r.

 We reconstruct the r elation r by taking the union of all fragments; that is,

 r = r1 ∪ r2 ∪ ···∪ rn
39 Prepared BY: Abebe SH. (MSc.) 1/16/2024
Horizontal Fragmentation
 Example; consider the following student relation.
 Assuming that there are only two collages in the university, CCI and CBE, the horizontal fragmentation
of student relation by college can be obtained as follows:
 Student Relation before fragmentation Fragment S1

Fragment S2

• Completeness:- Each tuple in the relation appears in either fragment S1 and S2


• Reconstruction:- The student relation can be reconstructed from the fragments using the union operation.
Thus; S1 U s2= student relation
• Disjointness:- The fragments are disjoint; there can be no student in both fragments (that is both ‘CCI’ and
Prepared BY: Abebe SH. (MSc.)
40‘CBE’). 1/16/2024
Vertical Fragmentation
 Vertical fragmentation divides a relation vertically by columns. A vertical fragment of a
relation keeps only certain attributes of the relation.
 For example, we may want to fragment the Student relation into two vertical
fragments.
 The first fragment includes personal information- Name and Sex and
 The second fragment includes education-related information- Stu_ID, College,
Department and CGPA
 This vertical fragmentation is not quite proper because,
 If the two fragments are stored separately, we cannot reconstruct the original
Student relation from the two fragments, since there is no common attribute between
the two fragments.
 It is necessary to include the primary key attribute in every vertical fragment so that
the full relation can be reconstructed from the fragments.
 Hence, we must add the Stu_ID attribute to the personal information fragment.
41 Prepared BY: Abebe SH. (MSc.) 1/16/2024
Vertical Fragmentation
 As a result the given Student can be vertically fragmented as follows,
Fragment S1 Fragment S2

 Completeness:- Each attribute in the student relation appears in either fragment S1 or S2.
 Reconstruction:- The student relation can be reconstructed from the fragments
 Disjointness:- The fragments are disjoint except for the primary key, which is necessary
for reconstruction the student relation.
42 Prepared BY: Abebe SH. (MSc.) 1/16/2024
Transparency
 The user of a distributed database system should not be required to know either where
the data are physically located or how the data can be accessed at the specific local site.
 This characteristic, called data transparency, can take several forms,
 Fragmentation transparency. Users are not required to know how a relation has been
fragmented.
 Replication transparency. Users view each data object as logically unique. The
distributed system may replicate an object to increase either system performance or
data availability.
 Users do not have to be concerned with what data objects have been replicated, or
where replicas have been placed.
 Location transparency. Users are not required to know the physical location of the
data.
 The distributed database system should be able to find any data as long as the data
identifier is supplied by the user transaction.
43 Prepared BY: Abebe SH. (MSc.) 1/16/2024
Distributed Transactions
 Access to the various data items in a distributed system is usually accomplished

through transactions, which must preserve the ACID properties.

 There are two types of transaction that we need to consider in DDBMS.

 Local Transactions are those that access and update data in only one local

database;
 Global Transactions are those that access and update data in several local

databases.

44 Prepared BY: Abebe SH. (MSc.) 1/16/2024


System Structure of a Distributed Database
 Each site has its own local transaction manager, whose function is to ensure the ACID

properties of those transactions that execute at that site.

 The various transaction managers cooperate to execute global transactions.

 To understand how such a manager can be implemented, consider an abstract model of a

transaction system, in which each site contains two subsystems:


o The Transaction Manager manages the execution of those transactions (or sub-transactions)

that access data stored in a local site.


 Note that each such transaction may be either a local transaction or part of a global

transaction.
o The Transaction Coordinator coordinates the execution of the various transactions (both local

and global) initiated at that site.


45 Prepared BY: Abebe SH. (MSc.) 1/16/2024
DDB System Failure Modes
 A distributed system may suffer from the same types of failure that a centralized

system does (for example, software errors, hardware errors, or disk crashes).

 There are, however, additional types of failure with which we need to deal in a

distributed environment. The basic failure types are:-


 Failure of a site

 Loss of messages

 Failure of a communication link

 Network partition

46 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Distributed Concurrency Control
 In Chapter 2 we have discussed the types of problems that can arise when multiple users

are allowed to access the database concurrently, namely the lost update problems,
uncommitted dependency problems, and inconsistent analysis problems.

 These problems also exist in the distributed environment.

 However, there are additional problems that can arise as a result of data distribution.

 One such problem is the multiple-copy consistency problem, which occurs when a data

item is replicated in different locations.

 Clearly, to maintain consistency of the global database, when a replicated data item is

updated at one site all other copies of the data item must also be updated.
 If a copy is not updated, the database becomes inconsistent.
Prepared BY: Abebe SH. (MSc.)
47 1/16/2024
Distributed Concurrency Control
 The various locking protocols described in Chapter 2 can be used in a distributed
environment.
 The only change that needs to be incorporated is in the way the lock manager
deals with replicated data.
 In this section we will see the following locking protocols that can be employed
to ensure serializability for distributed DBMSs:
Single Lock-Manager Approach

Distributed Lock Manager Approach

Primary Copy Approach

Majority Protocol Approach


48 Prepared BY: Abebe SH. (MSc.) 1/16/2024
Single Lock-Manager Approach
 In the single lock-manager approach, the system maintains a single lock manager that
resides in a single chosen site—say Si.
 All lock and unlock requests are made at site Si.
 When a transaction needs to lock a data item, it sends a lock request to Si. The lock
manager determines whether the lock can be granted immediately.
 If the lock can be granted, the lock manager sends a message to that effect to the
site at which the lock request was initiated.
 Otherwise, the request is delayed until it can be granted, at which time a message is
sent to the site at which the lock request was initiated.
 The transaction can read the data item from any one of the sites at which a replica of
the data item resides.
 In the case of a write, all the sites where a replica of the data item resides must be
involved in the writing.

49 Prepared BY: Abebe SH. (MSc.) 1/16/2024


Single Lock-Manager Approach

 The scheme has these advantages:

 Simple implementation. This scheme requires two messages for handling lock

requests and one message for handling unlock requests.


 Simple deadlock handling. because all lock and unlock requests are made at one site.

 The disadvantages of the scheme are:

 One is that all locking requests are sent to a single site, possibly over loading that site

and causing a system bottleneck.


 A second disadvantage is that failure of the primary site paralyzes the system, since all

locking information is kept at that site. This can limit system reliability and

50
availability.
Prepared BY: Abebe SH. (MSc.) 1/16/2024
Distributed Lock Manager
 This protocol attempts to overcome the disadvantages of Single lock-manager approach,
this time by distributing the lock managers to every site.
 Each site maintains a local lock manager whose function is to administer the lock and
unlock requests for those data items that are stored in that site.
 When a transaction wishes to lock a data item X that is not replicated and resides at site
Si, a message is sent to the lock manager at site Si requesting a lock (in a particular lock
mode).
 If data item X is locked in an incompatible mode, then the request is delayed until it can be
granted.
 Once it has determined that the lock request can be granted, the lock manager sends a message
back to the initiator transaction indicating that it has granted the lock request.
 The distributed-lock-manager scheme has the advantage of simple implementation, and
reduces the degree to which the coordinator is a bottleneck.
 However, deadlock handling is more complex, since the lock and unlock requests are no
longer made at a single site: There may be inter-site deadlocks even when there is no
51 Prepared BY: Abebe SH. (MSc.) 1/16/2024
deadlock within a single site.
Primary Copy
 For each replicated data item, one copy is chosen as the primary copy; the other copies
are called slave copies.
 The choice of which site to choose as the primary site is flexible, and the site that is
chosen to manage the locks for a primary copy need not hold the primary copy of that
item.
 It is only necessary to exclusively lock the primary copy of the data item that is to be
updated. Once the primary copy has been updated, the change can be propagated to the
slave copies.
 The disadvantages of this approach are that deadlock handling is more complex owing to
multiple lock managers, and that there is still a degree of centralization in the system:

52  lockPrepared
requests
BY: Abebefor a specific primary copy can be handled only by one site.
SH. (MSc.) 1/16/2024
Majority Protocol
 This protocol is an extension of distributed lock manager to overcome having to lock all

copies of a replicated item before an update.

 Again, the system maintains a lock manager at each site to manage the locks for all data at

that site.

 When a transaction wishes to read or write a data item that is replicated at n sites, it must

send a lock request to more than half of the n sites where the item is stored.

 The transaction cannot proceed until it obtains locks on a majority of the copies

 If the transaction does not receive a majority within a certain timeout period, it cancels

its request and informs all sites of the cancellation.


 If it receives a majority, it informs all sites that it has the lock.
53 Prepared BY: Abebe SH. (MSc.) 1/16/2024
Majority Protocol
 Any number of transactions can simultaneously hold a shared lock on a majority of

the copies; however, only one transaction can hold an exclusive lock on a majority
of the copies.

 Again, this scheme avoids the drawbacks of centralized control.

 The disadvantages are that the protocol is more complicated and deadlock

detection is more complex

54 Prepared BY: Abebe SH. (MSc.) 1/16/2024


55 Prepared BY: Abebe SH. (MSc.) 1/16/2024

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy