0% found this document useful (0 votes)
60 views56 pages

National University of Modern Languages - NUML: (Department of Computer Science)

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 56

National University of Modern

Languages - NUML
(Department of Computer Science)
Mr. Muhammad Noman Farooq
BSC-H (Computer Science)
MS (Telecomm. and Networks)
DWH & BI – Certified

Honors:
Gold Medalist!
Magna Cumm Laude
7 + years of Experience in Lectureship & Professional Trainings
Teradata + MySQL (Advanced) + Power BI + Tableau
Official E-Mail: [email protected]
Personal Email: [email protected]
Introduction to Database Systems

Relational Algebra

Lecture# 10
Lecture 10: Relational Algebra

 Relational Algebra

3
 Relational Algebra

4
Relational Algebra
 It is a language in which we can ask questions (query) to a database.

 The relational algebra is a theoretical language with operations that


work on one or more relations to define another relation without
changing the original relation(s).

 There are many variations of the operations that are included in


relational algebra. Codd (1972) originally proposed eight operations, but
several others have been developed.

 The five fundamental operations in relational algebra are Selection,


Projection, Cartesian product, Union, and Set difference, perform most
of the data retrieval operations that we are interested in.

5
Continued…
 In addition, there are also the Join, Intersection, and Division Operations,
which can be expressed in terms of the five basic operations. The function
of each operation is illustrated in Figure 4.1 on next slide.

 The Selection and Projection operations are Unary Operations, since they
operate on one relation.

 The other operations work on pairs of relations and are therefore called
Binary Operations.

 In the following definitions on next slides, let R and S be two


relations/tables defined over the attributes:

A = (a1, a2, . . . , aN) and B = (b1, b2, . . . , bM), respectively.

6
Continued…

1.Unary Operations:

1) Selection Operation
2) Projection Operation

2.Set Operations:

1) Union Operation
2) Set Difference Operation
3) Intersection Operation
4) Cartesian Product Operation

7
Continued…

3. Join Operations:

1) Theta/Equi Join Operation


2) Natural Join Operation
3) Left Outer Join Operation
4) Semi Join Operation

4. Division Operations:

1) Division Operation

5. Aggregate & Grouping Operations:

1. Aggregate Operation
2. Grouping Operation
8
9
1. Unary Operations:

1) Selection or Restriction Operation: -

10
2) Projection Operation: -

13
15
2. Set Operations:
1) Union Operation: -

16
18
2) Set Difference Operation: -

19
21
3) Intersection Operation: -

22
23
24
25
26
4) Cartesian Product Operation: -

27
29
30
31
3. Join Operations:
1) Theta/Equi Join Operation: -

32
33
2) Natural Join Operation: -

34
35
36
3) Left Outer Join Operation: -

37
38
39
4) Semi Join Operation: -

40
41
42
4. Division Operations:

1) Division Operation: -

43
44
45
5. Aggregate & Grouping Operations:

1) Aggregate Operation: -

46
47
48
2) Grouping Operation: -

49
50
51
52
Recommended Readings

Chapter 4 from: -

Database Systems-A Practical Approach to Design,


Implementation and Management by Thomas Connolly
and Carolyn BEGG, 4th Edition (Page No. 139-153)

53
Summary of Lecture
➦ Lecture 10
 Relational Algebra

1.Unary Operations:

1) Selection Operation
2) Projection Operation

2.Set Operations:

1) Union Operation
2) Set Difference Operation
3) Intersection Operation
4) Cartesian Product Operation 54
Summary of Lecture
➦ Lecture 10
3.Join Operations:

1) Theta/Equi Join Operation


2) Natural Join Operation
3) Left Outer Join Operation
4) Semi Join Operation

4.Division Operations:
1) Division Operation

5.Aggregate & Grouping Operations:


1) Aggregate Operation
2) Grouping Operation
55
 END OF LECTURE 10

56

You might also like