keeps only the attributes you list:
text
π dept_name (instructor)instructor9 tuples
keep dept_name
dept_name9 values, some the same
remove duplicates
π dept_name (instructor)5 tuples
A relation is a set
π returns a relation, and a relation never holds the same tuple twice. SQL tables can hold duplicate rows. So the SQL for π needs DISTINCT:
| Expression | SQL | Rows |
|---|---|---|
π dept_name (instructor) | SELECT DISTINCT dept_name FROM instructor | 5 |
| (not projection) | SELECT dept_name FROM instructor | 9 |
Duplicates are removed over all listed attributes together. π dept_name, salary keeps two tuples with the same department when their salaries are different.
Combine with σ
Select first, then project:
text
π name, salary (σ dept_name = 'Physics' (instructor))sql
SELECT DISTINCT name, salary FROM instructor WHERE dept_name = 'Physics';The order matters. After π, only the listed attributes exist. A σ above π can test only those attributes.