Relational Operations

COMP9315 23T1 ♢ Relational Operations ♢ [0/11]
❖ DBMS Architecture (revisited)

Implementation of relational operations in DBMS:

[Diagram:Pics/scansortproj/dbmsarch-relop.png]

COMP9315 23T1 ♢ Relational Operations ♢ [1/11]
❖ Relational Operations

DBMS core = relational engine, with implementations of

In this part of the course: Terminology reminder:
COMP9315 23T1 ♢ Relational Operations ♢ [2/11]
❖ Relational Operations (cont)

In order to implement relational operations the low-levels of the system provides:

COMP9315 23T1 ♢ Relational Operations ♢ [3/11]
❖ Relational Operations (cont)

Example of using low-level functions

// scan a relation Emps
Page p;  // current page
Tuple t; // current tuple
Relation r = relOpen(db,"Emps");
for (int i = 0; i < nPages(r); i++) {
   p = request_page(rel,i);
   for (int j = 0; j < nRecs(p); j++)
      t = mkTuple(r, get_record(p,j));
      ... process tuple t ...
   } 
}

COMP9315 23T1 ♢ Relational Operations ♢ [4/11]
❖ Relational Operations (cont)

Two "dimensions of variation":

Each query method involves an operator and a file structure: We are interested in cost  of query methods (and insert/delete operations)
COMP9315 23T1 ♢ Relational Operations ♢ [5/11]
❖ Relational Operations (cont)

SQL vs DBMS engine

COMP9315 23T1 ♢ Relational Operations ♢ [6/11]
❖ Cost Models

An important aspect of this course is

Cost can be measured in terms of Primary assumptions in our cost models:
COMP9315 23T1 ♢ Relational Operations ♢ [7/11]
❖ Cost Models (cont)

Since time cost is affected by many factors

we do not consider time cost in our analyses.

For comparing methods, page cost is better

Estimating costs with multiple concurrent ops and buffering is difficult!!

Addtional assumption: every page request leads to some i/o

COMP9315 23T1 ♢ Relational Operations ♢ [8/11]
❖ Cost Models (cont)

In developing cost models, we also assume:

[Diagram:Pics/scansortproj/file-struct0.png]

COMP9315 23T1 ♢ Relational Operations ♢ [9/11]
❖ Cost Models (cont)

Our cost models are "rough" (based on assumptions)

But do give an O(x) feel for how expensive operations are.

Example "rough" estimation: how many piano tuners in Sydney?

Actual number of tuners in Yellow Pages = 120

Example borrowed from Alan Fekete at Sydney University.

COMP9315 23T1 ♢ Relational Operations ♢ [10/11]
❖ Query Types

Type SQL RelAlg a.k.a.
Scan select * from R R -
Proj select x,y from R Proj[x,y]R -
Sort select * from R
order by x
Sort[x]R ord
Sel1 select * from R
where id = k
Sel[id=k]R one
Seln select * from R
where a = k
Sel[a=k]R -
Join select * from R,S
where R.id = S.r
R Join[id=r] S -

Different query classes exhibit different query processing behaviours.
COMP9315 23T1 ♢ Relational Operations ♢ [11/11]


Produced: 1 Mar 2023