You are on page 1of 3

UNIT-1

CHAPTER 1.3
Lecture-3.1(Relational Algebra: Introduction, Syntax and Semantic)

Relational algebra

In database theory, relational algebra is a theory that uses algebric structures with a well -


founded semantics for modeling the data, and defining queries on it. The theory has been
introduced by Edgae F. Codd.

The main application of relational algebra is to provide a theoretical foundation for relational


databases, particularly query languages for such databases, chief among which is SQL.

Relational databases store tabular data represented as relations. Queries over relational
databases often likewise return tabular data represented as relations.

The main premise of the relational algebra is to define operators that transform one or more
input relations to an output relation.

Given that these operators accept relations as input and produce relations as output, they can
be combined and used to express potentially complex queries that transform potentially many
input relations (whose data are stored in the database) into a single output relation (the query
results).

Unary operators accept as input a single relation; examples include operators to filter certain
attributes (columns) or tuples (rows) from an input relation.

Binary operators accept as input two relations; such operators combine the two input relations
into a single output relation by, for example, taking all tuples found in either relation,
removing tuples from the first relation found in the second relation, extending the tuples of
the first relation with tuples in the second relation matching certain conditions, and so forth.

Other more advanced operators can also be included, where the inclusion or exclusion of
certain operators gives rise to a family of algebras.

 Relational algebra is a mathematical query language for relations.


 It is a set based query language:
 The input to each operator is one or more relations, sets of tuples.
 The output of each operator is a relation: a set of tuples.
 Relational algebra is based on a minimal set of operators that can be combined to
write complex queries.
 The meaning (semantics) of other query languages, i.e. SQL, are defined in terms of
relational algebra.
 SQL queries are translated to relational algebra.
 Databases implement relational algebra operators to execute SQL queries.
 Caveat: we will see a bag version of these operators for SQL later in the semester.
 Mathematical definition of database design (normalization) uses relational algebra.
Relational Algebra Overview
 Crucial operators (complete set):
 Union
 Set difference
 Selection
 Projection
 Cartesian Product
 Renaming
 Derived operators (added for convenience):
 Theta join
 Natural join
 Set intersection
 Each operator has a Greek symbol that starts with the same letter as the operator:
Select-sigma, Project-Pi, etc.

Relational algebra

• Basic set of operations for the relational model

• Similar to algebra that operates on numbers

• Operands and results are relations instead of numbers

 Relational algebra expression

• Composition of relational algebra operations

• Possible because of closure property

 Model for SQL

• Explain semantics formally

• Basis for implementations

• Fundamental to query optimization

Relation Algebra is a procedural query language for RDBMS (Relational Database


Management System). An Algebra based on the set of operators (like Arithmetic operator,
union, intersection relational operator, etc.) and operand. Edgar F. Codd created it for a
relational database. Relational Algebra provides a fundamental query for retrieving data from
databases. The retrieved result from algebra expression is a relation which formed from one
or more relations. Relational Algebra specifies many operations to manipulate relations.

Procedural Query Language is language in which user tells the system to perform a specific
operation to obtain the desired result.
SQL Query language used by users in these days based on the concept of relational algebra
and relational Calculus. In these days, most Commercial RDBMSs are not providing us the
platform or user interface for using Relational algebra query language. Relational algebra
considered as an integral part of the relational query. SQL query is parsed into Relational
algebra expression through parser than into executable code.

Algebra provides us a great range of operations to perform on relations. Relational Algebra


function can divide into two parts, Basic set operations, and Special Relational Operations.
Relational algebra used operand, operators, rules in algebraic expressions.

Basic set operations: Union, Intersection, Difference and Cartesian product.

Special Set Operations: Join, Selection, Projection, and Division

OTHER REFRENCES

•      Relational Model and Algebra — CSCI 4380 Database Systems 1 documentation


(rpi.edu)

•    Relational Algebra - What is Relational Algebra? - Computer Notes


(ecomputernotes.com)

•     Slide 1 (uwaterloo.ca)

SUGGESTED BOOK REFERENCES

1. Ramez Elmasri and Shamkant B. Navathe,“Fundamentals of Database System”, The


Benjamin / Cummings Publishing Co.
2. Korth and Silberschatz Abraham, “Database SystemConcepts”, McGraw Hall.
3. Pratt,”DBMS”, Cengage Learning.

You might also like