Rel algebra selection girija

15
R1 := σ C (R2) C is a condition (as in “if” statements) that refers to attributes of R2. R1 is all those tuples of R2 that satisfy C. selection milk milk_type price Al-marai Full_Fat 2.50 Al-marai Refresh 2.75 Lancor Full_Fat 2.50 Lancor Refresh 3.00 Prices := σ milk=‘Al-marai(Sells): milk milk_type Al-marai Full_Fat Al-marai Refresh Sells price 2.50 2.75 Display only the milk Al-marai 1 DR.GIRIJA NARASIMHAN

description

set theory, selection, relational algebra, database - all the exercise sildes i have downloaded or referred from websites. i just orgainsed as topicwise for readers, www.youtube.com - video is available (search as "dr.girija narasimhan")

Transcript of Rel algebra selection girija

Page 1: Rel algebra selection girija

R1 := σC (R2)

C is a condition (as in “if” statements) that refers to attributes of R2.

R1 is all those tuples of R2 that satisfy C.

selection

milk milk_type price Al-marai Full_Fat 2.50 Al-marai Refresh 2.75 Lancor Full_Fat 2.50 Lancor Refresh 3.00

Prices := σ milk=‘Al-marai’(Sells):

milk milk_type Al-marai Full_Fat Al-marai Refresh

Sells

price 2.50 2.75

Display only the milk Al-marai

1 DR.GIRIJA NARASIMHAN

Page 2: Rel algebra selection girija

2 DR.GIRIJA NARASIMHAN

Page 3: Rel algebra selection girija

For example, the operation SID=101 selects all tuples in the input relation which have the value 101 in column SID.

Exercise 1- selection Exercise 2- selection

Select only A which has value one

3 DR.GIRIJA NARASIMHAN

Page 4: Rel algebra selection girija

For example, the operation SID=101 selects all tuples in the input relation which have the value 101 in column SID.

Selection – exercise 1 & 2 Result

4 DR.GIRIJA NARASIMHAN

Page 5: Rel algebra selection girija

Selection – exercise 3

Select the employee whose age is less than 30 or salary is greater than 4000

5 DR.GIRIJA NARASIMHAN

Page 6: Rel algebra selection girija

Selection – exercise 3 solution

6 DR.GIRIJA NARASIMHAN

Page 7: Rel algebra selection girija

Selection – exercise 4

Select where placeofbirth and residence place have same value or same place.

7 DR.GIRIJA NARASIMHAN

Page 8: Rel algebra selection girija

Selection – exercise 4 solution

8 DR.GIRIJA NARASIMHAN

Page 9: Rel algebra selection girija

Selection – exercise 5

Select where person whose age is greater than or equal to 34

Select the person whose age and weight should be same

9 DR.GIRIJA NARASIMHAN

Page 10: Rel algebra selection girija

Selection – exercise 5 solution

10 DR.GIRIJA NARASIMHAN

Page 11: Rel algebra selection girija

Selection – exercise 6

11 DR.GIRIJA NARASIMHAN

Page 12: Rel algebra selection girija

Selection – exercise 6 solution

12 DR.GIRIJA NARASIMHAN

Page 13: Rel algebra selection girija

Selection – exercise 7

13 DR.GIRIJA NARASIMHAN

Page 14: Rel algebra selection girija

Selection – exercise 8

14 DR.GIRIJA NARASIMHAN

Page 15: Rel algebra selection girija

Selection – exercise 8 solution

15 DR.GIRIJA NARASIMHAN