Relational Algebra(1) 2Relational Algebra(1).pptx

FutureTechnologies3 28 views 43 slides Jul 07, 2024
Slide 1
Slide 1 of 43
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43

About This Presentation

Relational Algebra(1)


Slide Content

Relational Algebra

Database state for company

Relational Algebra Overview These operations enable a user to specify basic retrievel requests (Queries) The result of these operation is a new relation

Select operation Select the employee tuples whose department number is 4: (employee) (The number of columns) = (The number of columns) employee (The number of tubles (rows) staisfies the condition) Select the employee tuples whose salary is greater than 30000 (employee) (The number of columns) = (The number of columns) employee (The number of tubles (rows) staisfies the condition)  

Select operation (More than one condition) (employee) (employee) Employee Table   Eno Ename Dno Salary 4 35000 4 25000 3 30000 2 20000 -      

Select operation (Complex) Employee working Dno=4 and got salary >30000 or Dno=4 and got salary <20000 (employee)  

Project Operation To list each employee’s first and last name and salary from employee table (Employee) To list each employee’s snn , salary and address from employee table (Employee)   snn salary address snn salary address -- -- -- <=  

Select and project operations For employees working in Dno=5, list F n ame, ssn, salary Select project (employee). (all columns in emplyee table , the rows scatisfy the condition) ( ) (all rwos in table , the list columns(Fname,ssn,salary))  

Union operation Including a ll tubles that are either in R or in S or in both R and S Duplicate tubles are eliminated Two conditions 1- R and S have the same number of attributes 2- Each pair of coresponding attributes in R and S have the same data type  

Union operation Example1

Union operation Example2

Intersection operation R A ll tuples that are in both R and S  

Difference operation R I ncludes all tuples that are in R but not in S  

Join operation Campine related tuples from various relations

Join operation example1

Join operation example2 Suppose that we want to retrieve the name of the manager of each department Department.MGRSSN = Employee.SSN

EXAMPLE2

Join operation example3 Suppose that we want to retrieve the name of the project and name of the controlling department

Join operation example 4 Suppose that we want to retrieve the name of the employee and names of the projects that worked on

Natural join R equires the two join attributes have the same name in both relations.

Outer join
Tags