---
title: "RA: projects where all used bolts size 6"
subject: "Database Management System"
chapter: 3
key: "semester_6/database_management_system:ra-projects-all-used-bolts"
source: https://www.bctengineer.com/q/semester_6/database_management_system/ra-projects-all-used-bolts
site: BCT Engineering
---

# RA: projects where all used bolts size 6

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-projects-all-used-bolts
- Whole chapter: https://www.bctengineer.com/md/semester_6/database_management_system/chapter-3

## Question

Consider the relational schema:
employee (e_no, name, address)
project (p_no, p_name)
work (e_no, p_no)
part (part_no, part_name, qty, size)
use (e_no, p_no, part_no, number)
List names of projects such that every employee working on these projects has used a part "bolts" with size 6. (Write a relational algebra expression.)

## Short answer

Use difference: from all projects with workers, subtract those having any employee who did not use bolts size 6, then join project for name: π p_name (project ⋈ (π p_no(work) − π p_no(work − π e_no,p_no(use ⋈ σ part_name='bolts'∧size=6(part)))).

## Answer

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

The question needs "every employee of the project", so it is a "for all" query. It is solved with difference (or the division operator). Assumption: an employee counts only if he or she used the part on that same project.

#### Relational algebra expression
Step by step:
```text
B    = π part_no ( σ part_name = "bolts" ∧ size = 6 (part) )
Good = π e_no, p_no ( use ⋈ B )          -- (employee, project) pairs that used size-6 bolts
Bad  = π p_no ( work − Good )            -- projects having some employee who did not
All  = π p_no ( work )                   -- projects having at least one employee
Ans  = π p_name ( project ⋈ ( All − Bad ) )
```
In one line:
```text
π p_name ( project ⋈ ( π p_no (work) −
    π p_no ( work − π e_no, p_no ( use ⋈ π part_no ( σ part_name="bolts" ∧ size=6 (part) ) ) ) ) )
```

#### Explanation
- work − Good leaves the employees who work on a project but have not used size-6 bolts there.
- Their projects (Bad) are removed from all projects, so only projects in which every employee used the bolts remain.

#### Equivalent SQL (tested)
```sql
SELECT p.p_name FROM project p
WHERE p.p_no IN (SELECT p_no FROM work)
AND NOT EXISTS (
  SELECT 1 FROM work w WHERE w.p_no = p.p_no AND NOT EXISTS (
    SELECT 1 FROM use u JOIN part t ON t.part_no = u.part_no
    WHERE u.e_no = w.e_no AND u.p_no = w.p_no
      AND t.part_name = 'bolts' AND t.size = 6));
```

## Check yourself

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

1. What kind of query is 'every employee working on the project has used...'?
   A. A 'for all' query, solved with difference or division
   B. A simple selection
   C. A union query
   D. A cross product only
   Answer: A. Universal quantification needs difference or division. (Key point: For all query)

2. What does Good = pi e_no,p_no(use join B) hold?
   A. All employees
   B. Projects with no employees
   C. (employee, project) pairs that used size-6 bolts
   D. All bolts in part
   Answer: C. B is the size-6 bolts part_no; joining with use gives pairs that used them. (Key point: Good set)

3. What does Bad = pi p_no(work - Good) hold?
   A. Projects having some employee who did not use the bolts
   B. Projects where all used bolts
   C. Projects with no employees
   D. Bolt part numbers
   Answer: A. work - Good leaves employees who did not; their projects are bad. (Key point: Bad set)

4. Why compute All - Bad?
   A. To find projects without employees
   B. To delete bad employees
   C. To keep only projects where every employee used the bolts (and which have employees)
   D. To count bolts
   Answer: C. Removing bad projects from all projects leaves those satisfying the condition. (Key point: Final subtraction)

## Related in Database Management System

- [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: employees on no project](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Ara-emp-no-project) — Database Management System, chapter 3
- [RA: parts used in DBMS and MIS](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Ara-parts-both-dbms-mis) — Database Management System, chapter 3
- [RA: employees on project DBMS](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Ara-emp-project-dbms) — Database Management System, chapter 3
- [RA: employees in both DBMS and MIS](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Ara-emp-both-dbms-mis) — 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
