0% found this document useful (0 votes)
53 views8 pages

Introduction To Relational Algebra/relational Calculus and Select Operation

The document discusses relational algebra and relational calculus operations for querying a database. It introduces the select operation in relational algebra, which filters tuples in a relation based on a selection condition. It describes properties of the select operation including that it produces a new relation with the same schema. The document also introduces tuple relational calculus, which specifies queries in terms of tuple variables ranging over relations and conditions on those tuples.

Uploaded by

Sanjeev Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views8 pages

Introduction To Relational Algebra/relational Calculus and Select Operation

The document discusses relational algebra and relational calculus operations for querying a database. It introduces the select operation in relational algebra, which filters tuples in a relation based on a selection condition. It describes properties of the select operation including that it produces a new relation with the same schema. The document also introduces tuple relational calculus, which specifies queries in terms of tuple variables ranging over relations and conditions on those tuples.

Uploaded by

Sanjeev Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 8

Lecture 10

Introduction to relational Algebra/relational


calculus and select operation
Database State for COMPANY
All examples discussed below refer to the COMPANY database shown here.
Relational Algebra
• The basic set of operations for the relational model is known
as the relational algebra. These operations enable a user to
specify basic retrieval requests.

• The result of a retrieval is a new relation, which may have


been formed from one or more relations. The algebra
operations thus produce new relations, which can be further
manipulated using operations of the same algebra.

• A sequence of relational algebra operations forms a


relational algebra expression, whose result will also be a
relation that represents the result of a database query (or
retrieval request).
Unary Relational Operations
• SELECT Operation

SELECT operation is used to select a subset of the tuples from a relation that
satisfy a selection condition. It is a filter that keeps only those tuples that
satisfy a qualifying condition – those satisfying the condition are selected
while others are discarded.
Example: To select the EMPLOYEE tuples whose department number is
four or those whose salary is greater than $30,000 the following notation is
used:
 DNO = 4 (EMPLOYEE)
SALARY > 30,000 (EMPLOYEE)
In general, the select operation is denoted by <selection condition>(R) where the
symbol  (sigma) is used to denote the select operator, and the selection
condition is a Boolean expression specified on the attributes of relation R

Chapter 6-4
Unary Relational Operations
SELECT Operation Properties
– The SELECT operation <selection condition>(R) produces a relation S that has
the same schema as R

– The SELECT operation is commutative; i.e.,


 <condition1>(< condition2> ( R)) = <condition2> (< condition1> ( R))

– A cascaded SELECT operation may be applied in any order; i.e.,


 <condition1>(< condition2> (<condition3> ( R))
 = <condition2> (< condition3> (< condition1> ( R)))

– A cascaded SELECT operation may be replaced by a single selection with


a conjunction of all the conditions; i.e.,
 <condition1>(< condition2> (<condition3> ( R))
 = <condition1> AND < condition2> AND < condition3> ( R)))
Unary Relational Operations (cont.)
Relational Calculus
• A relational calculus expression creates a new relation, which is
specified in terms of variables that range over rows of the stored
database relations (in tuple calculus) or over columns of the
stored relations (in domain calculus).
• In a calculus expression, there is no order of operations to
specify how to retrieve the query result—a calculus expression
specifies only what information the result should contain. This is
the main distinguishing feature between relational algebra and
relational calculus.
• Relational calculus is considered to be a nonprocedural
language. This differs from relational algebra, where we must
write a sequence of operations to specify a retrieval request;
hence relational algebra can be considered as a procedural way
of stating a query.
Tuple Relational Calculus
• The tuple relational calculus is based on specifying a number of tuple variables. Each
tuple variable usually ranges over a particular database relation, meaning that the
variable may take as its value any individual tuple from that relation.
• A simple tuple relational calculus query is of the form
{t | COND(t)}
where t is a tuple variable and COND (t) is a conditional expression involving t. The
result of such a query is the set of all tuples t that satisfy COND (t).

Example: To find the first and last names of all employees whose salary is above
$50,000, we can write the following tuple calculus expression:

{t.FNAME, t.LNAME | EMPLOYEE(t) AND t.SALARY>50000}


The condition EMPLOYEE(t) specifies that the range relation of tuple variable t is
EMPLOYEE. The first and last name (PROJECTION FNAME, LNAME) of each
EMPLOYEE tuple t that satisfies the condition t.SALARY>50000 (SELECTION
 SALARY >50000 ) will be retrieved.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy