0% found this document useful (0 votes)
43 views40 pages

Advance Database System Ch.1 (Autosaved)

The document discusses concepts related to object-oriented databases including what a database management system is, advantages of object-oriented databases, and the typical steps involved in processing queries for an object-oriented database which include parsing and translating the query, optimizing the query, and evaluating the query. It also provides details on object-oriented database concepts such as objects, literals, atomic objects, and object persistence.

Uploaded by

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

Advance Database System Ch.1 (Autosaved)

The document discusses concepts related to object-oriented databases including what a database management system is, advantages of object-oriented databases, and the typical steps involved in processing queries for an object-oriented database which include parsing and translating the query, optimizing the query, and evaluating the query. It also provides details on object-oriented database concepts such as objects, literals, atomic objects, and object persistence.

Uploaded by

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

Wollega University

Department of Computer Science


Advanced Database Management system
BY Tadele D.
1/20/23

01/20/2023 2021 Acadamic Year 1


CHAPTER ONE
OBJECT ORIENTED DATABASE Concepts
o Database Management System (DBMS) contains information
about a particular enterprise
o Collection of interrelated data, Set of programs to access the data
and an environment that is both convenient and efficient to use
o The primary goal of a DBMS is to provide an environment that
makes it both convenient and efficient to retrieve and store the
database information.

01/20/2023 2021 Acadamic Year 2


Cont…
 An object-oriented database management system represents
information in the form of objects as used in object-
oriented programming.
 Object-oriented databases are a type of database management
system.
 Object-oriented databases add the database functionality to
object programming languages, creating more manageable code
bases.
 OODBMS allows object-oriented programmers to develop
products, store them as objects and replicate or modify existing
objects to produce new ones within OODBM
OODBMS

01/20/2023 2021 Acadamic Year 4


OODB Advantages and Disadvantages

Every database modeling technique has advantages and


disadvantages
  The main advantages are:
 Complex data and a wider variety of data types can be stored
 Easy to save and retrieve data quickly.
 Seamless integration with object-oriented programming languages.
 Easier to model the advanced real world problems.
 Extensible with custom data types
Object Database Standard
Potential advantage of having and adhering to standards type of
database system is that it helps in achieving:
 portability of database applications to execute a particular
application program on different systems
 interoperability, which generally refers to the ability of an
application to access multiple distinct systems.
 in Object Database Standards the same application program
may access some data stored under one ODBMS package, and
other data stored under another package.

01/20/2023 2021 Acadamic Year 6


Object Database Management Group(ODMG)

The ODMG is the data model upon which the object definition
language (ODL) and object query language (OQL) are used.
ODMG provides the data types, type constructors, and other
concepts that can be utilized in the ODL to specify object database
schemas.
Generally, ODMG provide a standard data model for OODB

01/20/2023 2021 Acadamic Year 7


Objects and Literals
o Objects and literals are the basic building blocks of the object model
o The main difference between the two is that an object has both an
object identifier and a current value, whereas a literal has only a
value but no object identifier
o Objects is User defined complex data types
o An object has structure or state (variables) and methods
(behavior/operations)

01/20/2023 2021 Acadamic Year 8


Cont…

An object is described by four characteristics


Identifier: a system-wide unique id for an object
Name: an object may also have a unique name in DB (optional)
Lifetime: determines if the object is persistent or transient
Structure: Construction of objects using type constructors
o The object identifier is a unique system-wide identifier
( Object_Id).
o Every object must have an object identifier and optionally be
given a unique name within a particular database to refer the
object in a program, and the system should be able to locate the
object given that name

01/20/2023 2021 Acadamic Year 9


literal
In the object model, a literal is a value that does not have an
object identifier
 There are three types of literals:
o atomic,
o collection, and
o Structured.
Atomic literals correspond to the values of basic data types
and are predefined.
Collection literals specify a value that is a collection of
objects or values but the collection itself does not have an
Object_Id.
Structured literals correspond roughly to values that are
constructed using the tuple constructor they include Date,
Interval, Time, and Timestamp as built-in structures

01/20/2023 2021 Acadamic Year 10


Atomic Objects
In the object model, any user-defined object that is not a
collection object is called an atomic object.
atomic object type is defined as a class by specifying its
properties and operations.
E.g.; in a UNIVERSITY database application, the user can specify
an object type (class) for Student objects
Most such objects will be structured objects;

01/20/2023 2021 Acadamic Year 11


Object Persistence vs transient
An OODBMS is often closely coupled with an OOPL
 The OOPL is used to specify the method implementations and
application code
Objects created may have different lifetimes in the database :
a. transient: allocated memory managed by the programming
language run-time system
 Transient objects exist in the executing program and
disappear once the program terminates.
 This exists temporarily during the execution of a program
but is not kept when the program terminates

01/20/2023 2021 Acadamic Year 12


Cont…
b. persistent: allocated memory and stored managed by ODBMS
runtime system.
 Persistent objects are stored in the database and persist after
program termination.
 This holds a collection of objects that is stored permanently in
the database and hence can be accessed and shared by
multiple programs
 Persistence is the storage of data from working memory so
that it can be restored when the application is run again
 Persistent objects are stored in the database and accessed from
the programming language

01/20/2023 2021 Acadamic Year 13


Assignment
 Describe Object-Oriented Database Model
 WHY OBJECT-ORIENTED DATABASE?
 Describe Different implementations of object databases
features
 How to create object in OODBMS
 Describe Architecture model for OODBMS
CHAPTER TWO
Query Processing and Optimization
 Query Processing is process by which the query results are
retrieved from a high-level query such as SQL .
☺A query expressed in a high-level Query Languages must first
be scanned, parsed, and validated.
☺ The scanner identifies the language tokens such as keywords,
attribute names, and relation names in the text of the query.
☺ The parser checks the scanned query syntax to determine
whether it is formulated according to the syntax rules of the query
language.
☺The query must also be validated, by checking that all attribute
and relation names are valid and semantically meaningful names in
the schema of the database.

01/20/2023 2021 Acadamic Year 15


Processing a Query
Typical steps in processing a high-level query

01/20/2023 2021 Acadamic Year 16


Cont…
☺The DBMS must then devise an execution strategy for retrieving
the result of the query from the database files
☺Query optimization is process of choosing a suitable
execution strategy for processing a query
☺The query optimizer module has the task of producing an
execution plan, and the code generator generates the code to
execute that plan
☺The runtime database processor has the task of running the
query code, whether in compiled or interpreted mode, to produce
the query result.
☺If a runtime error results, an error message is generated by the
runtime database processor.

01/20/2023 2021 Acadamic Year 17


Basic Steps in Query Processing
1.Parsing and translation
2.Optimization
3.Evaluation

01/20/2023 2021 Acadamic Year 18


Parsing and Translating the Query
☺It is used to convert the query into a form usable by the query
processing engine.
☺High-level query languages such as SQL represent a query as a
string, or tokens such as keywords, operators, operands, literal
strings, etc.
☺ The primary job of the parser is to extract the tokens from the
raw string of characters and translate them into the
corresponding internal data elements (i.e. relational algebra
operations and operands) and structures (i.e. query tree, query
graph).
☺The last job of the parser is to verify the validity and syntax of the
original query string.

01/20/2023 2021 Acadamic Year 19


Optimizing the Query

☺In this stage, the query processor applies rules to the internal
data structures of the query to transform these structures into
equivalent, but more efficient representations.

☺The rules can be based on the relational algebra


expression and tree (heuristics), upon cost estimates of
different algorithms applied to operations and the relations
it involves.

☺Selecting the proper rules to apply, when to apply them and


how they are applied is the function of the query.
01/20/2023 2021 Acadamic Year 20
Evaluating the Query
☺The final step in processing a query . The best evaluation
plan candidate generated by the optimization engine is selected
and then executed.
☺Note that there can exist multiple methods of executing a
query.
☺Regardless of the method chosen, the actual results should be
same.
☺Finding the optimal strategy is usually too time-consuming
except for the simplest of queries and may require information
on how the files are implemented
☺Hence, planning of an execution strategy may be a more
accurate description than query optimization.

01/20/2023 2021 Acadamic Year 21


Translating SQL Queries into Relational Algebra
☺SQL(non-procedural ) is the query language that is used in
most commercial RDBMS.

☺An SQL query is first translated into an equivalent extended


relational algebra expression as a query tree data structure and
then optimized.

☺Relational algebra is a procedural languages which takes


relation as input and produce relation as output

01/20/2023 2021 Acadamic Year 22


Cont…
☺SQL queries are decomposed into query blocks, which form
the basic units that can be translated into the algebraic operators
and optimized.
☺A query block contains a single SELECT-FROM-WHERE
expression, as well as GROUP BY and HAVING clauses if these
are part of the block.
☺The nested queries within a query are identified as
separate query blocks.
☺So, The query optimizer would then choose an execution plan
for each block.
☺The inner block needs to be evaluated only once to produce the
maximum salary which is called uncorrelated nested query.

01/20/2023 2021 Acadamic Year 23


01/20/2023 2021 Acadamic Year 24
Example2:
For every project located in ‘Stafford’, retrieve the project
number, the controlling department number and the
department manager’s last name, address and birthdate.
SQL query:
SELECT PNUMBER, DNUM, LNAME
FROM PROJECT, DEPARTMENT, EMPLOYEE
WHERE DNUM=DNUMBER and MGREMPID=EMPID and
PLOCATION = 'Stafford';
Relation algebra:
PNUMBER, DNUM, LNAME, ADDRESS, BDATE (((PLOCATION=‘STAFFORD’(PROJECT))
DNUM=DNUMBER (DEPARTMENT)) MGRSSN=SSN (EMPLOYEE))

01/20/2023 2021 Acadamic Year 25


Implementing Basic Query
Operations
• An RDBMS must provide implementation(s) for all the required
operations including relational operators
Internal Sorting
Each record contains a field called the key.
The keys can be places in a linear order.
External Sorting
 Refers an algorithms that are suitable for large files of records
stored on disk that do not fit entirely in main memory, such as most
database files.
Sort-merge strategy
o It Starts by sorting small sub files (runs) of the main file and then
merges the sorted runs, creating larger sorted sub files that are
merged in turn.
1. Sorting phase
2. Merging phase
01/20/2023 2021 Acadamic Year 26
Example1: External Sorting Using Sort-Merge

01/20/2023 2021 Acadamic Year 27


Cont…

1. Sorting phase
 Number of file blocks (b)
 Number of available buffers (nB)
 Runs file = (b / nB)
2. Merging phase ( passes)
 Degree of merging(dM) --- the number of runs that are merged together in
each pass
 dM=Min(nB-1,nR)
Analysis of the algorithm
Number of file blocks = b
Number of initial runs = nR
Available buffer space = nB
Sorting phase: nR = (b/nB)
Degree of merging: dM = Min (nB-1, nR);
Number of passes: nP = (logdM(nR))
Number of block accesses: (2 *2021
01/20/2023
b) Acadamic
+ (2 *Year
b * (np))) 28
Number of passes =
Total Cost of external sort-merge= 2N * (# of passes)
 To sort a file with N pages using B buffer pages:
 Pass 0: use B buffer pages. Produce sorted runs of B pages each.
Pass 2, …, etc.: merge B-1 runs.
E.g., with 5 buffer pages, to sort 108 page file:
 Pass 0: [108/5] = 22 sorted runs of 5 pages each (last run is only 3 pages)
 Pass 1: [22/4] = 6 sorted runs of 20 pages each (last run is only 8 pages)
 Pass 2:[6/3]= 2 sorted runs, 80 pages and 28 pages
 Pass 3: [2/1] =1 Sorted file of 108 pages
 Number of passes= 4(pass0,pass1,pass2 and pass3)
 Total Cost of external sort-merge= 2(108) * 4=864

01/20/2023 2021 Acadamic Year 29


Query Tree Optimization
Query optimization categorized into two types:
1. Heuristic (Rule based):the optimizer chooses execution plans
based on heuristically ranked operations.
2. Systematic (Cost based):the optimizer examines alternative
access paths and operator algorithms and chooses the execution
plan with lowest estimate cost.
Heuristic-Based Query tree Optimization
 Experience based techniques for problem solving, learning and
discovery

01/20/2023 2021 Acadamic Year 30


Steps to optimize queries in of heuristic optimization algorithm are:

1. Break up SELECT operations with conjunctive conditions into


a cascade of SELECT operations
2. Using the commutativity operations, move each SELECT
operation as far down the query tree as is permitted the select
condition
3. Using commutativity and associativity of binary operations,
rearrange the leaf nodes of the tree
4. Combine a CARTESIAN PRODUCT operation with a
subsequent SELECT operation in the tree into a JOIN operation,
if the condition allows
5. Using the cascading of PROJECT and the commuting of
operations, break down and move lists of projection
attributes down the tree as far as possible by creating new
PROJECT operations as needed
6. Identify sub-trees that represent groups of operations that can be
executed by a single algorithm
01/20/2023 2021 Acadamic Year 31
Example 3:Find the last names of employees born after 1957 who
work on a project named ‘Aquarius’.
SELECT LNAME   
FROM EMPLOYEE, WORKS_ON, PROJECT   
WHERE PNAME=‘Aquarius’ AND PNUMBER=PNO AND
ESSN=SSN AND BDATE.‘1957-12-31’;

01/20/2023 2021 Acadamic Year 32


01/20/2023 2021 Acadamic Year 33
01/20/2023 2021 Acadamic Year 34
01/20/2023 2021 Acadamic Year 35
01/20/2023 2021 Acadamic Year 36
01/20/2023 2021 Acadamic Year 37
Cont…

• The main goal behind query optimization is to reduce intermediate


results:
o This includes performing SELECT operation to reduce the number
of tuples and
o PROJECT operation to reduce number of attributes.

01/20/2023 2021 Acadamic Year 38


Assignment 1(10%)
1. Describe Object-Oriented Concepts . Give examples
2. Describe Advantages and Disadvantages of OODBMS
3. Describe how to create objects in DBMS
4. Discus different Data model
5. Describe different types of index in DMS.
a) Compare and contrast

01/20/2023 2021 Acadamic Year 39


Emerging Technology

You might also like