---
title: "RA: delete Electrical dept projects"
subject: "Database Management System"
chapter: 3
key: "semester_6/database_management_system:ra-delete-electrical-projects"
source: https://www.bctengineer.com/q/semester_6/database_management_system/ra-delete-electrical-projects
site: BCT Engineering
---

# RA: delete Electrical dept projects

Database Management System · Chapter 3: Relational Languages & Relational Model

- Asked in: year not given
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/database_management_system/ra-delete-electrical-projects
- Whole chapter: https://www.bctengineer.com/md/semester_6/database_management_system/chapter-3

## Question

Consider the relational schema:
emp (eid, name, add, sup_eid)
dep (dep_id, name)
project (pid, title, dep_id)
work (eid, pid, hours)
Delete projects belonging to Electrical dept. (Write a relational algebra expression.)

## Short answer

Find Electrical department dep_id, then delete matching projects by assignment: project ← project - (project ⋈ E).

## Answer

Relational algebra symbols used: σ select, π project, ⋈ natural join, ∪ union, ∩ intersection, − difference, ρ rename, 𝒢 aggregate.

#### Relational algebra expression
```text
E ← π dep_id ( σ name = "Electrical" (dep) )

project ← project − ( project ⋈ E )
```

#### Explanation
1. σ name="Electrical"(dep) selects the Electrical department, and π dep_id gives its id as relation E.
2. project ⋈ E keeps the projects whose dep_id matches (the join is on the common attribute dep_id). Because E has only dep_id, the result keeps the schema of project (pid, title, dep_id), so the difference is valid.
3. Subtracting these tuples from project deletes them, and the result is assigned back to project.

To keep the database consistent, the work tuples of the deleted projects should also be removed:
```text
work ← work − ( work ⋈ π pid ( project ⋈ E ) )
```
This must be done before project is changed, otherwise the pids can no longer be found.

#### Equivalent SQL
```sql
DELETE FROM project
WHERE dep_id IN (SELECT dep_id FROM dep WHERE name = 'Electrical');
```

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How is the Electrical department identified?
   A. σ dep_id(π name(dep))
   B. dep join work
   C. π pid(dep)
   D. π dep_id(σ name=Electrical(dep))
   Answer: D. Select the department then project its id. (Key point: Getting dep_id)

2. Why is project ⋈ E valid for the difference?
   A. E has all attributes
   B. E has only dep_id, so the result keeps project's schema
   C. Difference needs no compatibility
   D. The join adds a column
   Answer: B. Union compatibility is required. (Key point: Why join keeps schema)

3. Why delete work tuples before changing project?
   A. work is smaller
   B. project must be unchanged for dep
   C. It is faster
   D. Otherwise the pids of deleted projects can no longer be found
   Answer: D. The pids come from project ⋈ E. (Key point: Order of deletes)

## Related in Database Management System

- [RA: computer dept employees and supervisors](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Ara-computer-emp-supervisor) — Database Management System, chapter 3
- [RA: projects count per department](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Ara-projects-per-department) — Database Management System, chapter 3
- [RA: employees on Network over 15 hours](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Ara-network-project-15-hours) — Database Management System, chapter 3
- [RA: employee-projects with no part used](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Ara-emp-project-no-part) — Database Management System, chapter 3
- [RA: projects where all used bolts size 6](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Ara-projects-all-used-bolts) — Database Management System, chapter 3
- [RA: delete loans under 1000](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Ara-delete-small-loans) — Database Management System, chapter 3
