Professional Documents
Culture Documents
CH 01
CH 01
CH 01
System (ADBMS)
01/31/24
Advanced Database System 1
CHAPTER ONE
Object-Oriented DBMSs
01/31/24
Advanced Database System 2
Topics discussed in this chapter
Weaknesses of RDBMSs
01/31/24
Advanced Database System 3
Weaknesses of RDBMSs
Limited Operations.
01/31/24
Advanced Database System 4
What is an OODBMS ?
01/31/24
Advanced Database System 5
What is an OODBMS ?
Features of OODBs:
01/31/24
Advanced Database System 6
Object Oriented Concepts:
01/31/24
Advanced Database System 7
Objects
Object is a uniquely identifiable entity that contains both:
The attributes that describe the state of a real-world
object and the actions associated with it.
01/31/24
Advanced Database System 8
Specifying Object Persistence
The typical mechanisms for making an object persistent are Naming and
Reachability.
01/31/24
Advanced Database System 10
Object Identity (OID)
01/31/24
Advanced Database System 11
Object Identity (OID)
the OID value of a particular objet should not change. This preserves
Assume we have one object its name is Obj1 and OID:A123 then when
the object is deleted from the database since the OID is immutable we
can’t use to refer any other object. i.e. if an object is deleted its OID
01/31/24
Advanced Database System 12
Complex Objects
A Complex object is something that can be viewed as a single
object in the real world but it actually consists of many sub-
objects.
Two types of complex objects:
Unstructured complex objects:
• Their structure is hard to determine.
• Requires a large amount of storage.
• BLOB (Binary Large Objects): images and
• CLOB(character long objects): large strings.
Structured complex objects:
• Clear structure. E.g tuple
01/31/24
Advanced Database System 13
Object Structure
In OODB, the value of a complex object can be constructed from
other objects
01/31/24
Advanced Database System 3-14
Type constructors
01/31/24
Advanced Database System 15
Type constructors
Kind of basic constructors are:
Atom: is used to represent all basic atomic values such as int, char,
01/31/24
Advanced Database System 16
Type Constructors
Tuple constructor TUPLE OF
Name|Set of locations|Array of emp
It represent in the form of : <A1:i1, A2:i2….An:in>
Eg: <Name :i1, Set of locations:i2,Array of emp: i3>
Set constructor SET OF
Many elements of the same type build a set.
Each element can only be contained once in the set.
Multi-set constructor BAG OF: like set but
one element can have copies in the bag
List constructor LIST OF: like bag, but
The OIDs in a list are ordered, and hence we can refer to the first,
second, or nth object in a list Sequence is of interest
17
01/31/24
Advanced Database System
Object Structure
Object state interpreted based on constructor ‘C’
01/31/24
Advanced Database System 3-19
Object Structure
Example:
p le
if c = tuple then v = < a1:i1..an:in > a rt m en t t u
d e p
A
01/31/24
Advanced Database System 3-20
Object Structure
Example:
if c = set then v = {i1,i2,i3}
o7 = (i7, set, { i2, i1 , i3 } )
o10 = (i10, set, { i12, i13 , i14 } )
o11 = (i11, set, { i15, i16 , i17 } )
A set
of em p
loyees
01/31/24
Advanced Database System 3-21
Classes
Classes are blueprints for defining a set of similar
objects. Or common description of similar objects.
Objects in a class are called instances.
Class is also an object with own class attributes and
class methods.
Object created from the same class share the same
class attributes and methods.
01/31/24
Advanced Database System 22
Class Instance Share Attributes & Methods
BranchNo = B005
Street = 22 Deer Rd
City = London
Postcode = SW1 4EH
BRANCH
Attributes
branchNo BranchNo = B007
street Street = 16 Argyll St
city
postcode City = Aberdeen
Postcode = AB2 3SU
Methods
print()
getPostCode()
numberOfStaff() BranchNo = B003
Street = 163 Main St
City = Glasgow
Postcode = G11 9QX
01/31/24
Advanced Database System 23
OO Data Modelling: Unified Modeling Language (UML)
01/31/24
Advanced Database System 24
Unified Modeling Language (UML)
PERSON
Name
FName
LName
01/31/24
Advanced Database System 3-26
Chapter Two
27
Introduction
Query Processing
Activities involved in retrieving data from the database.
28
Query Processing…
29
Basic Steps in Query Processing
1. Parsing and translation
2. Optimization
3. Evaluation
3-30
Parsing and translation
Scanner: The scanner specifies and recognizes the language tokens such as
SQL Keywords, attribute names, and relation names in the text of the query.
Validation: The query must be validated by checking that all attributes and
relation names are valid and semantically meaningful names in the schema of
3-31
Parsing and translation
as branches
Each operator has implementation choices.
32
Translating SQL Queries into Relational Algebra
Query block:
The basic unit that can be translated into the algebraic operators
and optimized.
Nested queries:
33
Translation Example
balance(balance<2500(account))
3-34
Translating SQL Queries into Relational Algebra
35
Translating SQL Queries into Relational Algebra
36
Translating SQL Queries into Relational Algebra
Relational Algebra:
3-38
Execution plan
query optimization.
39
Evaluation
When the query came how the database answer it?
3-40
Relational Algebra: overview
Project (unary)
A1 A 2 A 3 … A n A1 A 2… A k
i j
...
...
n K, n≥k 41
Project
42
Relational Algebra: Select
Select or Restrict
<predicate> (R)
43
Pictorially
Movie title year length filmType
Star Wars 1977 124 color
Mighty result set
1991 104 color
Ducks
Wayne’s
1992 95 color
World
A1 A 2 A 3 … A n A1 A 2 A 3 … A n
i j, i j
...
...
# of selected tuples is referred to as the selectivity of the condition
44
Cartesian Product
R x S
45
Example
R S
A B B C D A R.B S.B C D
1 2 2 5 6 1 2 2 5 6
x
3 4 4 7 8 1 2 4 7 8
9 10 11 1 2 9 10 11
3 4 2 5 6
3 4 4 7 8
3 4 9 10 11
46
Join Operations
47
Example
R S
A B B C D A B C D
1 2 2 5 6 1 2 5 6
join
3 4 4 7 8 3 4 7 8
9 10 11
48
Optimization
A relational algebra expression may have many equivalent expressions
E.g.,salary75000(salary(instructor)) is equivalent to
salary(salary75000(instructor))
3-50
Three Key Concepts in QPO
1. Building blocks
Similarly, most DBMS have few building blocks:
• select (point query, range query), join, sorting, ...
SQL query is decomposed in building blocks
balancebalance<2500(account))
balance
balance<2500
account
3-53
Making An Evaluation Plan
Annotate Query Tree with evaluation instructions:
balance
account
The query can now be executed by the query execution engine.
3-54
Tree Representation of Relational Algebra
A1,,,,Anp( R1 x,….Rk))
A1,,,An
P
x Rk
x
R1 R3
R2 3-55
Why Learn about QPO?
Why learn about QPO in a DBMS?
Identify performance bottleneck for a query
• is it the physical data model or QPO ?
How to help QPO speed up processing of a query ?
• providing hints, rewriting query, etc.
How to enhance physical data model to speed up
queries?
• add indices, change file- structures, …
3-56
Measures of Query Cost
Cost is generally measured as total elapsed time for answering
query
Many factors contribute to time cost
3-57
Algorithms for select operations
Implementing the SELECT Operations
58