Docsity

Relational Algebra and Database Systems: An Introduction, Slides of Distributed Database Management Systems

Partial preview of the text

Download Relational Algebra and Database Systems: An Introduction and more Slides Distributed Database Management Systems in PDF only on Docsity!

In the name of ALLAH

Introduction to

Database Systems

Lecture

Spring 2012

Relational Algebra

 Relational algebra operations

work on one or more relations

to define another relation

leaving the original intact.

Relational Algebra

 Both operands and results are

relations, so output from one

operation can become input to

another operation.

Relational Algebra

 5 basic operations in relational

algebra: Selection, Projection,

Cartesian product, Union, and

Set Difference.

Relational Algebra

 These perform most of the data

retrieval operations needed.

 Also have Join, Intersection, and

Division operations, which can be

expressed in terms of 5 basic

operations.

Select

 Selects tuples that satisfy a given

predicate

 Notation is Greek symbol sigma:

 PREDICATE ( RELATION)

Select

 To process a selection,

– Look at each tuple

– See if we have a match (based on

the condition)

Selection Example

stId stName stAdr prName curSem

S1020 Sohail Dar H#14, F/8- 4,Islamabad.

MCS 4

S1038 Shoaib Ali H#23, G/9- 1,Islamabad

BCS 3

S1015 Tahira Ejaz H#99, Lala Rukh Wah.

MCS 5

S1018 Arif Zia H#10, E-8, Islamabad.

BIT 5

Selection Example

1. σ Curr_Sem > 3 (STUDENT)

2. σ Studid = „S1038‟ (STUDENT)

Selection

Example Cont’d)

  1. σ (^) Salary > 27000 (FAC)
  2. σ(Salary>26000) or (Rank=„Asso Prof‟) (FAC)

Thanks

Projection

 Notation

 a1, a2, ..., ak (R)

where a 1 ... ak are attribute names and R

is a relation name

Projection

 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.