Professional Documents
Culture Documents
Need to develop efficient implementation of simple relational operations. Need for automatic query optimization. Unavailability of efficient software techniques. Requirement of increased processing power. Requirement of increased I/O speed.
Attribute a fixed number of columns Tuples a variable number of rows Cardinality total number of rows Degree total number of attributes Domain a set of atomic values Key unique identifier
Relational Algebra
Relational algebra is a collection of operations for the relational model to manipulate or access relations. These operations enable a user to specify retrieval requests. The result of a retrieval is 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.
<selection condition> (R) The symbol (sigma) is used to denote the SELECT operator.
The selection condition is a Boolean expression specified on the attributes of relation R.
<condition1>( <condition2>
(R)) =
<condition2> ( <condition1>
( R)))
(R))
A cascaded SELECT operation may be replaced by a single selection with a conjunction of all the conditions
(R)
The general form of the PROJECT operation is given as: PROJECT table(orrelation)nameONcolumnname(s) Into RESULT
In general, the project operation is denoted by
LNAME, FNAME,SALARY
(EMPLOYEE)
NATURAL JOIN Operation NATURAL JOIN ( denoted by *) requires that the two join attributes, or each pair of corresponding join attributes, have the same name in both relations. If this is not the case, a renaming operation is applied first.
Result T1
- T2
Relational Calculus
Relational calculus consists of two calculi, the tuple relational calculus and domain relational calculus, that are part of the relational model for databases and provide a declarative way to specify database queries. This in contrast to the relational algebra which is also part of the relational data model but provides a more procedural way for specifying queries. Thus, in a relational calculus, there is no description of how to evaluate a query; a relational calculus query specifies what is to be retrieved rather than how to retrieve it. The relational algebra and the relational calculus are essentially logically equivalent: for any algebraic expression, there is an equivalent expression in the calculus, and vice versa.
Relational Calculus
The relational algebra might suggest these steps to retrieve the phone numbers and names of book stores that supply Some Sample Book: Join book stores and titles over the BookstoreID. Restrict the result of that join to tuples for the book Some Sample Book. Project the result of that restriction over StoreName and StorePhone. The relational calculus would formulate a descriptive, declarative way: Get StoreName and StorePhone for supplies such that there exists a title BK with the same BookstoreID value and with a BookTitle value of Some Sample Book.