Sql – What are projection and selection

databaserelational-algebrasql

What is the difference between projection and selection? Is it:

  • Projection –> for selecting the columns of table; and
  • Selection —> to select the rows of table?

So are projection and selection vertical and horizontal slicing respectively?

Best Answer

Exactly.

Projection means choosing which columns (or expressions) the query shall return.

Selection means which rows are to be returned.

if the query is

select a, b, c from foobar where x=3;

then "a, b, c" is the projection part, "where x=3" the selection part.