# 0.4 Relational algebra

 Page 1 / 3
In this lecture, we will discuss the first formal languages for the relational models: Relational Algebra

In this lecture, we will discuss the first formal languages for the relational models: Relational Algebra

## Relational algebra

Relational Algebra (RA) can be viewed as a data manipulation language for relational model. It consists of several basic operations which is enable user to specify retrieval requests. RA is called a procedural language in which user need to specify how to retrieve the expected data.

Relational Algebra has the following components:

• Operands: Relations or Variables that represent relations
• Operators that map relations to relations
• Rules for combining operands and operators to relational algebra expression
• Rules for evaluating those expressions

Operations of relational algebra include the followings:

• Union, Intersect, Set Difference, Cartesian Product are operations based on set theory
• Select, Project, Join, Division are operations developed especially for relational databases. Example Database

## Relational algebra operations from set theory

Definition: Two relations r(A1, A2, …, An) and s(B1, B2, …, Bn) are union compatible if they have the same degree n and dom(Ai) = dom(Bi) for 1 ≤ i ≤ n.

This mean two union compatible relations have the same number of attributes and each corresponding pair of attributes have the same domain

1. UNION Operation

The UNION operation combines two union compatible relations into a single relation via set union of sets of tuples.

• Notation: $\mathrm{r1}\cup \mathrm{r2}$ Union Operation Notation
• $\mathrm{r1}\cup \mathrm{r2}=\left\{t\mid t\in \mathrm{r1}\vee t\in \mathrm{r2}\right\}$ where r1(R) and r2(R)
• Result size:  $\mid \mathrm{r1}\cup \mathrm{r2}\mid \le \mid \mathrm{r1}\mid +\mid \mathrm{r2}\mid$
• Result schema: R
• Producing the result of UNION
• Make a copy of relation r1
• For each tuple t in relation r2, check whether it is in the result or not. If it is not already in the result then place it there.
• Example: Union Operation Example
1. INTERSECTION Operation

The INTERSECTION operation combines two union compatible relations into a single relation via set intersection of sets of tuples.

• Notation: $\mathrm{r1}\cap \mathrm{r2}$ Intersection Operation Notation
• $\mathrm{r1}\cap \mathrm{r2}=\left\{t\mid t\in \mathrm{r1}\wedge t\in \mathrm{r2}\right\}$ where r1(R) and r2(R)
• Result size: $\begin{array}{}\mid \mathrm{r1}\cap \mathrm{r2}\mid \le \text{min}\left(\mid \mathrm{r1}\mid ,\mid \mathrm{r2}\mid \right)\\ \end{array}$
• Result schema: R
• Producing the result of INTERSECTION
• Initially, result set is empty
• For each tuple t in relation r1, if t is in the relation r2 then place t in the result set.
• Example Intersection Operation Example
1. SET DIFFERENCE Operation

The DIFFERENCE operation finds the set of tuples that exist in one relation but do not occur in the other union compatible relation

• Notation: r1 \ r2 Difference Operation Notation
• $\begin{array}{}\\ \mathrm{r1}=\left\{t\mid t\in \mathrm{r1}\wedge t\notin \mathrm{r2}\right\}\end{array}$ where r1(R) and r2(R)
• Result schema: R
• Producing the result of the DIFFERENCE operation
• Initially, result set is empty
• For each tuple in r1, check whether it appear in r2 or not. If it does not then place it in the result set. Otherwise, ignores it
• Example Difference Operation Example
1. CARTESIAN PRODUCT Operation

The PRODUCT operation combines information from two relations pairwise on tuples.

• Notation: r x s
• $r×s=\left\{\left(\mathrm{t1},\mathrm{t2}\right)\mid \mathrm{t1}\in r\wedge \mathrm{t2}\in s\right\}$ where r(R) and s(S)
• Each tuple in the result contains all attributes in r and s, possibly with some fields renamed to avoid ambiguity. The result set contains all possible tuple that can be construct from one tuple in r and one tuple in s.
• Result schema: If we have R(A1, A2, …, An) and S(B1, B2, …, Bm) then the list of attributes in Result is (A1, A2, …, An, B1, B2, …, Bm)
• Result size: $\mid r×s\mid =\mid r\mid \ast \mid s\mid$
• Producing the result of PRODUCT operation:
• For each tuple in r, form new tuples by pair it with each tuple in s
• Place all of these new tuples in the result set
• Example

#### Questions & Answers

how can chip be made from sand
Eke Reply
is this allso about nanoscale material
Almas
are nano particles real
Missy Reply
yeah
Joseph
Hello, if I study Physics teacher in bachelor, can I study Nanotechnology in master?
Lale Reply
no can't
Lohitha
where is the latest information on a no technology how can I find it
William
currently
William
where we get a research paper on Nano chemistry....?
Maira Reply
nanopartical of organic/inorganic / physical chemistry , pdf / thesis / review
Ali
what are the products of Nano chemistry?
Maira Reply
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
learn
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
learn
Google
da
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Bhagvanji
hey
Giriraj
Preparation and Applications of Nanomaterial for Drug Delivery
Hafiz Reply
revolt
da
Application of nanotechnology in medicine
has a lot of application modern world
Kamaluddeen
yes
narayan
what is variations in raman spectra for nanomaterials
Jyoti Reply
ya I also want to know the raman spectra
Bhagvanji
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
Nasa has use it in the 60's, copper as water purification in the moon travel.
Alexandre
nanocopper obvius
Alexandre
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
LITNING Reply
what is a peer
LITNING Reply
What is meant by 'nano scale'?
LITNING Reply
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

### Read also:

#### Get Jobilize Job Search Mobile App in your pocket 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? By By OpenStax By OpenStax By OpenStax By OpenStax By OpenStax By OpenStax By OpenStax By Robert Murphy By Rylee Minllic