I'm referring to the basic relational algebra operators here.
As I see it, everything that can be done with project can be done with select.
I don't know if there is a difference or a certain nuance that I've missed.
Prerequisite – Relational Algebra. Project operation selects (or chooses) certain attributes discarding other attributes. The Project operation is also known as vertical partitioning since it partitions the relation or table vertically discarding other columns or attributes. Notation: πA(R)
The SELECT operation is used for selecting a subset of the tuples according to a given selection condition. Sigma(σ)Symbol denotes it. It is used as an expression to choose tuples which meet the selection condition. Select operator selects tuples that satisfy a given predicate.
Project Operation The project SQL operation allows users of the relational model to retrieve column-specific data from a table. This data is then used to create a new table that is dedicated to the information that the user would like to see.
The selection operator is unary, which means it is applied to one table at a time. The result is a new table that has the same structure as the original. The operation takes rows from the original table that satisfy a specified condition, called the selection condition, producing a horizontal subset of the table.
PROJECT eliminates columns while SELECT eliminates rows.
Select Operation : This operation is used to select rows from a table (relation) that specifies a given logic, which is called as a predicate
. The predicate is a user defined condition to select rows of user's choice.
Project Operation : If the user is interested in selecting the values of a few attributes, rather than selection all attributes of the Table (Relation), then one should go for PROJECT
Operation.
See more : Relational Algebra and its operations
In Relational algebra 'Selection' and 'Projection' are different operations, but the SQL SELECT combines these operations in a single statement.
Select retrieves the tuples (rows) in a relation (table) for which the condition in 'predicate' section (WHERE clause) stands true.
Project retrieves the attributes (columns) specified.
The following SQL SELECT query:
select field1,field2 from table1 where field1 = 'Value';
is a combination of both Projection and Selection operations of relational algebra.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With