Docsity

Data Manipulation Languages-Introduction to Database System-Lecture Slides, Slides of Introduction to Database Management Systems

Partial preview of the text

Download Data Manipulation Languages-Introduction to Database System-Lecture Slides and more Slides Introduction to Database Management Systems in PDF only on Docsity!

In the name of ALLAH

Introduction to

Database Systems

Lecture

Spring 2012

Department of Computer Science

Relational Algebra

 Relational algebra operations

work on one or more relations

to define another relation

leaving the original intact.

Department of Computer Science

Relational Algebra

 Both operands and results are

relations, so output from one

operation can become input to

another operation.

Department of Computer Science

Relational Algebra

 5 basic operations in relational

algebra: Selection, Projection,

Cartesian product, Union, and

Set Difference.

Department of Computer Science

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.

Department of Computer Science

Select

 Selects tuples that satisfy a given

predicate

 Notation is Greek symbol sigma:

 PREDICATE ( RELATION)

Department of Computer Science

Select

 To process a selection,

– Look at each tuple

– See if we have a match (based on

the condition)

Department of Computer Science

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

Department of Computer Science

Selection Example

1. σ Curr_Sem > 3 (STUDENT)

2. σ Studid = „S1038‟ (STUDENT)

Department of Computer Science

Selection

Example Cont’d)

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

Thanks

Department of Computer Sciencedocsity.com

Department of Computer Science

Projection

 Notation

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

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

is a relation name

Department of Computer Science

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.