44

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.

DaveyDaveDave
  • 9,821
  • 11
  • 64
  • 77
gizgok
  • 7,303
  • 21
  • 79
  • 124
  • 7
    Herbalessence's answer is totally correct, but the basic idea is: with the selection operator you specify which rows you want, with the projection operator you specify which columns you want. – SáT Mar 25 '11 at 18:08
  • 3
    Please note that this question is about relational algebra operators as opposed to SQL's SELECT statement. Read @EmergeStronger's answer for a clearer explanation of the differences. – shrmn Dec 01 '15 at 01:53
  • Selecting means choosing some records from a table and leaving others out. Projecting means choosing some columns from each record and leaving others out – Numan Naqshbndi Jan 29 '17 at 15:18

10 Answers10

69

PROJECT eliminates columns while SELECT eliminates rows.

Krishna Pal
  • 691
  • 5
  • 2
64

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

Saurabh Gokhale
  • 53,625
  • 36
  • 139
  • 164
31

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.

EmergeStronger
  • 311
  • 3
  • 2
  • 1
    As gizgok's question was clearly in reference to SQL, this should be the accepted answer – Bryan Sep 08 '21 at 21:42
11

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

user4980372
  • 111
  • 1
  • 3
2

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

Mohammad Heydari
  • 3,933
  • 2
  • 26
  • 33
1

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

0

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.

rashedcs
  • 3,588
  • 2
  • 39
  • 40
0

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.

0

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

0

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