<< Chapter < Page Chapter >> Page >
Catesian Product Operation Notation
Catesian Product Operation Example
  • Note: As we can notice, the CARTESIAN PRODUCT operation by itself is not a useful querying mechanism since the result size is large. However, it is an extremely important operation of relational algebra since it is the basic mechanism for combining information across relations. We will discuss about this topic in more detail in Query Processing lecture.

Other relational algebra operations

  1. SELECT Operation

The SELECT operation is an unary operation. It means the input of this operation is only one relation and it output is also a relation.

The SELECT operation returns a subset of the tuples from a relation that satisfies a selection condition. The SELECT operation can be viewed as a horizontal filter of the relation. It partitions the input relation into two sets of tuples: those tuples that satisfies the condition are select, those do not satisfy the condition are discarded.

  • Notation: σ selection condition > ( r ) size 12{σ rSub { size 8{ ital "selection"` - ` ital "condition"}} \( r \) } {}
Select Operation Notation
  • σ F ( r ) = { t t r F ( t ) } size 12{σ rSub { size 8{F} } \( r \) `=` lbrace t \lline `t in `r and `F \( t \) rbrace `} {} where r(R) and F is a boolean expression on attributes in R

The selection condition is made up of a number of clauses of the form

  • <attribute name><comparison op><constant value>OR
  • <attribute name 1><comparison op><attribute name 2>

In the clause, the comparison operations could be one of the following: ≤, ≥, ≠, =,>,<. Clauses are connected by Boolean operators : and, or , not

  • Result size σ F ( r ) r size 12{ \lline σ rSub { size 8{F} } \( r \) \lline<= ` \lline r \lline `} {}
  • Result schema: R
  • Producing the result of the SELECT operation
    • Selection condition F is evaluate for each tuple in r, with the attribute variables in F set to their values in the tuples
    • Any tuple t that F(t) = true is placed in the result set
    • Other tuples are not include in the result.
  • Example: Retrieve the Id, Name, Suburb of students who live in Bundoora
Select Operation Example - 1
  • Example: Retrieve the Id, Name, Suburd of student who’s name is Mary or students who live in Bundoora
Select Operation Example - 2
  1. PROJECT Operation

The PROJECT operation is another unary operation. This operation returns a set of tuples containing a subset of the attributes in the original relation. Thus, as we state that the SELECT operation selects some rows and discards the others. The PROJECT operation, on the other hand, selects some columns of the relation and discards the other column. The PROJECT operation can be viewed as the vertical filter of the relation.

  • Notation: π attribute list ( r ) size 12{π rSub { size 8{ ital "attribute"` - ital "list"} } \( r \) } {}
Project Operation Notation
  • π X ( r ) = { t [ X ] t r } size 12{π rSub { size 8{X} } \( r \) `=` lbrace t` \[ X \] ` \lline t in `r rbrace ` } {} where r(R)
  • Result size: π X ( r ) r size 12{ \lline π rSub { size 8{X} } \( r \) \lline<= ` \lline r \lline `} {}
  • Result schema: R’(X)
  • Producing the result of PROJECT operation
    • Take each tuple in the original relation, extract the values of the specified attributes
    • Form new tuple from these values and place the new tuple in the result if it is not already there. This steps includes the duplicate removal phase, this makes the result of PROJECT operation a relation
  • Example: Retrieve the suburbs that are stored in database
Project Operation Example - 1
  • Retrieve the name of the subjects and department which is responsible for the subject

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Algebra. OpenStax CNX. Aug 17, 2012 Download for free at http://cnx.org/content/col11445/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Algebra' conversation and receive update notifications?

Ask