Back to Basics – What is the Difference between Selection and Projection?

These concepts are related to the sql statement in oracle and in RDBMS in general.

Projection

This is a vertical subset of table columns (the select list) , including all rows.
It may include one column, two columns or all table columns.
Projection answers the question: which columns the query shall return?

For example:
select empno , ename, job from emp;

Selection:

This is a horizontal subset of table columns (some rows) , including all columns.
It may include one row, two rows or all table rows.
Selection answers the question: which rows the query shall return (the where condition)?

For example:
select * from emp where deptno = 10;

Usually, one query contains both: selection and projection:
select empno , ename , job from emp where deptno=10;

Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s