What are projection and selection?

2019-01-10 12:36发布

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?

4条回答
男人必须洒脱
2楼-- · 2019-01-10 12:43

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

查看更多
smile是对你的礼貌
3楼-- · 2019-01-10 12:47

Projections and Selections are two unary operations in Relational Algebra and has practical applications in RDBMS (relational database management systems).

In practical sense, yes Projection means selecting specific columns (attributes) from a table and Selection means filtering rows (tuples). Also, for a conventional table, Projection and Selection can be termed as vertical and horizontal slicing or filtering.

Wikipedia provides more formal definitions of these with examples and they can be good for further reading on relational algebra:

查看更多
祖国的老花朵
4楼-- · 2019-01-10 12:51

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

查看更多
一纸荒年 Trace。
5楼-- · 2019-01-10 13:02

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.

查看更多
登录 后发表回答