[go: up one dir, main page]

0% found this document useful (0 votes)
39 views3 pages

Relational Algebra: Nested Operations

Nested operations in relational algebra involve using the result of one operation as input for another, akin to SQL subqueries. The document provides examples of using AND and OR conditions to find employees in specific departments with certain salary criteria. It demonstrates how to combine these conditions using nested operations to retrieve the desired results from a relation named Employees.

Uploaded by

ahmadd8572
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views3 pages

Relational Algebra: Nested Operations

Nested operations in relational algebra involve using the result of one operation as input for another, akin to SQL subqueries. The document provides examples of using AND and OR conditions to find employees in specific departments with certain salary criteria. It demonstrates how to combine these conditions using nested operations to retrieve the desired results from a relation named Employees.

Uploaded by

ahmadd8572
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

MALIK AHMED JAMIL

DATABASE SYSTEMS

2420040302-003

MA’AM MASHAL

DEPARTMENT OF COMPUTER SCIENCES

AND SOFTWARE ENGINEERING


WHAT IS NESTED OPERATION IN RELATIONAL ALGEBRA?

Nested Operations:

Nested operations in relational algebra refer to queries that use one operation as an input for
another operation. This is similar to subqueries in SQL. The result of one operation is used as
the operand for another operation.

Example: Finding with AND and OR

Consider a relation (table) named Employees:

Employee ID Name Department Salary Experience


201 Aisha Human Resources 55000 5
202 Bilal Engineering 70000 8
203 Fatima Marketing 60000 4
204 Hassan Engineering 50000 3
205 Zoya Finance 75000 10

Problem: Using AND and OR with Nested Operations

1. Find employees in the Engineering department with a Salary > 60000.


2. Find employees in either the Marketing or Finance departments.
3. Combine both conditions using a nested operation.

Solution in Relational Algebra

1. AND Condition

Find employees in the Engineering department with a Salary > 60000


σ Department= ′ Engineering ′ ∧Salary>60000 (Employees)

Result:

Employee ID Name Department Salary Experience


202 Bilal Engineering 70000 8
OR Condition
Find employees in either the Marketing or Finance departments:
σ Department= ′ Marketing ′ ∨Department= ′ Finance ′ (Employees)

Result:

Employee ID Name Department Salary Experience


203 Fatima Marketing 60000 4
205 Zoya Finance 75000 10

Nested Operation (Combine AND and OR)


Find employees who satisfy either of these conditions:

• Department = 'Engineering' AND Salary > 60000


• Department = 'Marketing' OR Department = 'Finance'

σ Department= ′ Engineering ′ ∧Salary>60000 (Employees)∪

σ Department= ′ Marketing ′ ∨Department= ′ Finance ′ (Employees)

Result:

Employee ID Name Department Salary Experience


202 Bilal Engineering 70000 8
203 Fatima Marketing 60000 4
205 Zoya Finance 75000 10

You might also like