What are projection and selection?

prabhahar picture prabhahar · Jun 23, 2009 · Viewed 128.6k times · Source

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?

Answer

Erich Kitzmueller picture Erich Kitzmueller · Jun 23, 2009

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.