Selection keeps rows whose predicate is true.

highlighted = computed this step

Selection filters rows

Selection keeps rows whose predicate is true and drops the rest. It matters because it changes cardinality without changing the columns. Note: result rows appear only in the diagrams.

σ keeps matching rows\sigma\text{ keeps matching rows}

First selection

The first predicate keeps the matching enrollments shown in the rendered table. The recomputed row count is 2 and the recomputed arity is 2. Note: arity is unchanged because selection does not remove columns.

rows=2,arity=2\text{rows}=2,\quad \text{arity}=2

set algebra not SQL bag/NULL, tiny finite tables, no product/perf claims

Selectionselect course eq DBarity 2 rows 2Enrollarity 2 rows 3
selectsidcourses1DBs2DB

Second selection

The second predicate is more selective, so fewer rows survive. The recomputed row count is 1 and the recomputed arity is still 2. Note: selectivity varies with the predicate and the data.

rows=1,arity=2\text{rows}=1,\quad \text{arity}=2

set algebra not SQL bag/NULL, tiny finite tables, no product/perf claims

Selection contrastselect course eq OSarity 2 rows 1Enrollarity 2 rows 3
selectsidcourses1OS

Summary

Selection filters cardinality while preserving arity. Note: SQL duplicate handling and NULL predicate behavior are deferred to the next book.

selection summary\text{selection summary}