You are on page 1of 10

Advanced Database System (Comp 449)

By Solomon Tadesse

Revision from the previous course


Relational data Structure What is a relation?
 A table with columns and rows

Attribute?
 Is a named column of a relation

Domain?
 The set of allowable values for one or more attributes

Tuple?
 A row of a relation.

Revision...
Degree?
The number of attributes a relation contains.

Cardinality?
The number of tuples a relation contains.

A relation schema?
R(A1,A2,A3,....,An) Example
Staff(staffNo, fName, lName, position, sex, DOB, salary, branchNo)

Revision...
Relational Algebra Is a theoretical language with operations that work on one or more relations to define another relation without changing the original relation. Has five fundamental operations
Selection Projection Unary Cartesian product Union Binary Set Difference

There are also other operations


Join, Intersection and Division

Revision...
Selection
 The SELECT operation is used to select a subset of the tuples from a relation that satisfy a selection condition.

<selection condition>(R)

 Example: salary>1000(Staff) Projection  Projection operation works on a single relation R and defines a relation that contains a vertical subset of R, extracting the values of specified attributes and eliminating duplicates.  a1,a2,a3,....,an(R)  Example:
staffNo,fName,lName,salary(Staff)

Revision...
Union  The union of two relations R and S defines a relation that contains all the tuples of R, or S, or both R and S, duplicate tuples being eliminated.  Union-Compatible Set Difference  The set difference operation defines a relation consisting of the tuples that are in relation R, but not in S.  Union-Compatible Intersection  A relation consisting of the set of all tuples that are in both R and S.  Union-Compatible

Revision...
Cartesian Product(x)  Defines a relation that is the concatenation of every tuple of relation R with every tuple of relation S.
SID RET/001/01 RET/028/01 RET/345/01 SID RET/001/01 RET/028/01 RET/345/01 Name Andualem Birhanu Melat Course Code Comp 449 Comp 207 Comp 449 Department Computer Science Civil Engineering Electrical Engineering

RxS

SID RET/001/ 01 RET/001/ 01 RET/001/ 01 RET/028/ 01 RET/028/ 01 RET/028/ 01 RET/345/ 01 RET/345/ 01 RET/345/ 01

Name Anduale m Anduale m Anduale m Birhanu Birhanu Birhanu Melat Melat Melat

Department Computer Science Computer Science Computer Science Civil Engineering Civil Engineering Civil Engineering Electrical Engineering Electrical Engineering Electrical Engineering

SID

Course Code

RET/001/ Comp 449 01 RET/028/ Comp 207 01 RET/345/ Comp 449 01 RET/001/ Comp 449 01 RET/028/ Comp 207 01 RET/345/ Comp 449 01 RET/001/ Comp 449 01 RET/028/ Comp 207 01 RET/345/ Comp 449 01

Revision...
Join  Why join instead of cartesian product?  Different types of joins
 Theta join( -join) R
F

 Defines a relation that contains tuples satisfying the predicate F from the Cartesian product of R and S. The predicate F is of the form R.ai S.bi, where may be one of the comparison operators.  R R.SID=S.SID S

 Natural Join
 Is an Equijoin of the two relations R and S over all common attributes x. One occurence of each common attribute is eliminated from the result.

 Outer join
 A join in which tuples from R that do not have matching values in the common attributes of S are also included in the result relation.

 Semijoin
 Produces a relation that contains the tuples of R that participate in the join of R with S satisfying the predicate F.

SID RET/001/ 01 RET/028/ 01 RET/345/ 01

Name Anduale m Birhanu Melat

Department Computer Science Civil Engineering Electrical Engineering

SID

Course Code

RET/001/ Comp 449 01 RET/028/ Comp 207 01 RET/345/ Comp 449 01

You might also like