What are projection and selection?

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?


Solution 1:

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.

Solution 2:

Simply PROJECTION deals with elimination or selection of columns, while SELECTION deals with elimination or selection of rows.

Solution 3:

Projection: what ever typed in select clause i.e, 'column list' or '*' or 'expressions' that becomes under projection.

*selection:*what type of conditions we are applying on that columns i.e, getting the records that comes under selection.

For example:

  SELECT empno,ename,dno,job from Emp 
     WHERE job='CLERK'; 

in the above query the columns "empno,ename,dno,job" those comes under projection, "where job='clerk'" comes under selection