SQL to Relational Algebra

1) Query 1

SQL:

SELECT name FROM Students WHERE city = 'Chittagong';

Relational Algebra:

π_name (σ_city='Chittagong'(Students))

Explanation: Selects names of students whose city is 'Chittagong'.

2) Query 2

SQL:

SELECT product_name FROM Products WHERE price > 500;

Relational Algebra:

π_product_name (σ_price>500(Products))

Explanation: Selects product names where the price is greater than 500.

3) Query 3

SQL:

SELECT name FROM Doctors WHERE specialization = 'Cardiology' OR experience < 3;

Relational Algebra:

π_name (σ_specialization='Cardiology' ∨ experience<3 (Doctors))

Explanation: Selects doctor names who either specialize in 'Cardiology' or have less than 3 years of experience.

4) Query 4

SQL:

SELECT title FROM Movies WHERE release_year >= 2020;

Relational Algebra:

π_title (σ_release_year≥2020(Movies))

Explanation: Selects titles of movies released in or after 2020.

5) Query 5

SQL:

SELECT employee_name FROM Employees WHERE department = 'IT' AND salary > 80000;

Relational Algebra:

π_employee_name (σ_department='IT' ∧ salary>80000 (Employees))

Explanation: Selects names of employees in the 'IT' department with salary over 80000.

একটি মন্তব্য পোস্ট করুন