# 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.

## 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}$
• $\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:
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}$
• $\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
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
• $\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
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

Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
Maciej
characteristics of micro business
Abigail
for teaching engĺish at school how nano technology help us
Anassong
Do somebody tell me a best nano engineering book for beginners?
s. Reply
there is no specific books for beginners but there is book called principle of nanotechnology
NANO
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
NANO
so some one know about replacing silicon atom with phosphorous in semiconductors device?
s. Reply
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
SUYASH Reply
for screen printed electrodes ?
SUYASH
What is lattice structure?
s. Reply
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
what is biological synthesis of nanoparticles
Sanket Reply
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 the best Algebra and trigonometry course in your pocket!

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 Danielrosenberger By By Eric Crawford By Mistry Bhavesh By By Anindyo Mukhopadhyay