gizgok
gizgok

Reputation: 7649

What is the difference between Select and Project Operations

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.

Upvotes: 46

Views: 148024

Answers (10)

Malala Victor
Malala Victor

Reputation: 1

The difference come in relational algebra where project affects columns and select affect rows. However in query syntax, select is the word. There is no such query as project. Assuming there is a table named users with hundreds of thousands of records (rows) and the table has 6 fields (userID, Fname,Lname,age,pword,salary). Lets say we want to restrict access to sensitive data (userID,pword and salary) and also restrict amount of data to be accessed. In mysql maria DB we create a view as follows ( Create view user1 as select Fname,Lname, age from users limit 100;) from our view we issue (select Fname from users1;) . This query is both a select and a project

Upvotes: 0

Binod Regmi
Binod Regmi

Reputation: 1

select just changes cardinality of the result table but project does change both degree of relation and cardinality.

Upvotes: 0

Shaykh Aawmir
Shaykh Aawmir

Reputation: 1

The difference between the project operator (π) in relational algebra and the SELECT keyword in SQL is that if the resulting table/set has more than one occurrences of the same tuple, then π will return only one of them, while SQL SELECT will return all.

Upvotes: 0

rashedcs
rashedcs

Reputation: 3725

Select extract rows from the relation with some condition and Project extract particular number of attribute/column from the relation with or without some condition.

Upvotes: 0

Mohammad Heydari
Mohammad Heydari

Reputation: 4290

Project will effects Columns in the table while Select effects the Rows. on other hand Project is use to select the columns with specefic properties rather than Select the all of columns data

Upvotes: 2

user4980372
user4980372

Reputation: 131

Project is not a statement. It is the capability of the select statement. Select statement has three capabilities. They are selection,projection,join. Selection-it retrieves the rows that are satisfied by the given query. Projection-it chooses the columns that are satisfied by the given query. Join-it joins the two or more tables

Upvotes: 13

akanksha malik
akanksha malik

Reputation: 11

selection opertion is used to select a subset of tuple from the relation that satisfied selection condition It filter out those tuple that satisfied the condition .Selection opertion can be visualized as horizontal partition into two set of tuple - those tuple satisfied the condition are selected and those tuple do not select the condition are discarded sigma (R) projection opertion is used to select a attribute from the relation that satisfied selection condition . It filter out only those tuple that satisfied the condition . The projection opertion can be visualized as a vertically partition into two part -are those satisfied the condition are selected other discarded Π(R) attribute list is a num of attribute

Upvotes: 1

EmergeStronger
EmergeStronger

Reputation: 351

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.

Upvotes: 35

Krishna Pal
Krishna Pal

Reputation: 711

PROJECT eliminates columns while SELECT eliminates rows.

Upvotes: 71

Saurabh Gokhale
Saurabh Gokhale

Reputation: 46405

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

Upvotes: 65

Related Questions