SlideShare a Scribd company logo
1 of 23
Fundamental
Relational algebra
PREPARED BY
Ms.K.Kannika -III-B.Sc - Information Technology
Ms.R.Thirupurasundari -III-B.Sc-Information Technology
UNDER THE GUIDANCE OF
Mrs.P.Anusha M.Sc(IT).,M.Phil.,D.P.T.T.,(Ph.D).,
Assistant professor,
Department of Information Technology,
Bon secours college for women,
Thanjavur.
RelAtional algebra :
 Relational algebra is a procedural query language. It
gives a step by step process to obtain the result of the
query, it uses operators to perform queries
 Relational algebra operation work on one or more relation
to define another relation without changing the original
relations.
The fundamental operations of relational algebra are as
follows :
 Select
 Project
 Union
 Set difference
 Cartesian products
 Rename
Selection operation:
 The select operation selects tuples that satisfy a given predicate
 It is denoted sigma (σ)
 Notation : σP(r)
Where,
σ is used for selection prediction
r is used for relation
P is used for propositional logic formula which may use
connectors like : AND, OR and NOT. The relation can be use as
relational operators like =, ≠, <=, >=, <, >
Example :
Table : Student
Create table student(name varchar(255), age int, mark1 int, mark2
int) ;
Insert into Student values(‘abirami’,’18’,’89’,’67’) ;
Insert into student values(brindha, 18,79,97) ;
Insert into student values(‘seetha’,’19’, ’81’,’84’);
Select *from student ;
Name Age Mark 1 Mark2
Abirami 18 89 67
Brindha 18 79 97
Seetha 19 81 84
σ name =‘Brindha’(student) ;
Name Age Mark1 Mark2
Brindha 18 79 97
Project operation :
 This operation shows the list of those attributes that we
wish to appear in the result
 Rest of the attributes are eliminated from the table
 It is denoted by π
 Notation : πA1, A2,.........,An (r)
Example :
πname, mark1(student) ;
Name Mark1
Abirami 89
Brindha 79
Seetha 81
Union operation :
 Suppose there are two tuples R and S. The Union
operation contains all the tuple that are either in R or S Or
both in R & S
 It eliminates the duplicate tuple
 It is denoted by U
 Notation: R U S
 r U s = {t/t ∈ r or t ∈ s}
A union operation must hold the following condition :
 R and S must have the attribute of the same number
 Duplicate tuple are eliminated automatically
Example :
Table : student
Table : student1
Create table student1(name varchar (255), age int, mark1 int, mark2);
Insert into student1 values('seetha‘, ’19’, ’85’,’ 84’) ;
Insert into student1 values(‘gobi’, ’20’, ‘95’, ’66’) ;
Insert into student1 values (‘revathi’, ’19’, ’85’, ’77’) ;
select * from student1;
Name Age Mark1 Mark2
Seetha 19 85 84
Gobi 20 95 66
Revathi 19 85 77
π name, mark1(student) U πname, mark1(student1) ;
Output :
Name Mark 1
Abirami 89
Brindha 79
Seetha 81
Revathi 85
Gobi 95
Set intersection :
 Suppose there are two tuples R and S. The set intersection
operation contain all tuples that are in both R & S
 It is denoted by intersection ∩
 Notation : R ∩ S
Example :
πname (student) ∩ πname(student) ;
Name
Seetha
Set difference:
 The result set of difference operation is tuples, which are
present in one relation but are not in the second relation
 It is denoted by - minus
 Notation : R-S
Example:
πname(student) – πname(student1) ;
OUTPUT:
Name
Abirami
Brindha
Cartesian products:
 The cartesian product is used to combine each row in one
table with each row in the other table it is also known as a
cross product
 It is denoted by X
Example :
Table : A
Create table A( id_no int, age int, city varchar(255)) ;
Insert into A values (’01’, ‘25‘, ‘chennai’) ;
Insert into A values (’02’, ’24’, ‘Bangalore‘) ;
Select * from A;
Id_no Age City
01 25 Chennai
02 24 Bangalore
Table B :
Create table B(exam varchar(20) , mark1 int, mark2 int) ;
Insert into B values ('CIA‘, ’64’, ’56’) ;
Insert into B values(‘model’, ’69’, ’98’) ;
Exam Mark1 Mark2
CIA 64 56
Model 69 98
OUTPUT: A X B
Id_no Age City Exam Mark1 Mark2
01 25 Chennai CIA 64 56
01 25 Chennai Model 69 98
02 24 Bangalore CIA 64 56
02 24 Bangalore Model 69 98
Rename operation :
 The result of relational algebra are also relations but without any
name, the rename operation allows as to rename the output relation.
‘Rename’ operation is denoted with small Greek letter rho ρ
 Notation: ρ × (E)
 Where the result of the expression E is saved with name of x
 We can use the rename operator the rename STUDENT relation to
STUDENT 2
 ρ(Student 2,student) ;
FORMAL DEFINITION:
 A General expression in the relational algebra is constructed out of
smaller sub expressions.Let E1 and E2 be relational algebra
expressions.Then the following are all relational algebra
expressions:
 E1 U E2 , E1 ∩ E2
 E1 – E2
 E1 X E2
 (σ) p (E1) Where P is a predicate on attributes in E1.
 Π S(E1) Where S is a list consisting of sum of the attributes in E1.
 ρ x (E1) Where x is the new name for the result of E1.

More Related Content

Similar to fundamental relation algebra.pptx

CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
mydrynan
 
Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]
Palak Sanghani
 
Lecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculusLecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculus
emailharmeet
 

Similar to fundamental relation algebra.pptx (20)

Python
PythonPython
Python
 
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
 
Relational Database and Relational Algebra
Relational Database and Relational AlgebraRelational Database and Relational Algebra
Relational Database and Relational Algebra
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
Python cheatsheat.pdf
Python cheatsheat.pdfPython cheatsheat.pdf
Python cheatsheat.pdf
 
Unit_3.pdf
Unit_3.pdfUnit_3.pdf
Unit_3.pdf
 
Introduction to Data Science With R Lab Record
Introduction to Data Science With R Lab RecordIntroduction to Data Science With R Lab Record
Introduction to Data Science With R Lab Record
 
Functions Practice Sheet.docx
Functions Practice Sheet.docxFunctions Practice Sheet.docx
Functions Practice Sheet.docx
 
Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]
 
Engineering Computers L32-L33-Pointers.pptx
Engineering Computers L32-L33-Pointers.pptxEngineering Computers L32-L33-Pointers.pptx
Engineering Computers L32-L33-Pointers.pptx
 
Csci101 lect08b matlab_programs
Csci101 lect08b matlab_programsCsci101 lect08b matlab_programs
Csci101 lect08b matlab_programs
 
K map
K mapK map
K map
 
object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lectures
 
3306617
33066173306617
3306617
 
Basic Analysis using R
Basic Analysis using RBasic Analysis using R
Basic Analysis using R
 
Lecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculusLecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculus
 
MATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfMATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdf
 
VARIOUS FUZZY NUMBERS AND THEIR VARIOUS RANKING APPROACHES
VARIOUS FUZZY NUMBERS AND THEIR VARIOUS RANKING APPROACHESVARIOUS FUZZY NUMBERS AND THEIR VARIOUS RANKING APPROACHES
VARIOUS FUZZY NUMBERS AND THEIR VARIOUS RANKING APPROACHES
 
Python For Machine Learning
Python For Machine LearningPython For Machine Learning
Python For Machine Learning
 

More from Anusha sivakumar (14)

deadline.pptx
deadline.pptxdeadline.pptx
deadline.pptx
 
Evolution of Computers ppt.pptx
Evolution of Computers ppt.pptxEvolution of Computers ppt.pptx
Evolution of Computers ppt.pptx
 
set operators.pptx
set operators.pptxset operators.pptx
set operators.pptx
 
PURPOSE OF DATABASE final.pptx
PURPOSE OF DATABASE final.pptxPURPOSE OF DATABASE final.pptx
PURPOSE OF DATABASE final.pptx
 
NESTED SUBQUERY.pptx
NESTED SUBQUERY.pptxNESTED SUBQUERY.pptx
NESTED SUBQUERY.pptx
 
join relation.pptx
join relation.pptxjoin relation.pptx
join relation.pptx
 
DBMS ARCHITECTURE.pptx
DBMS ARCHITECTURE.pptxDBMS ARCHITECTURE.pptx
DBMS ARCHITECTURE.pptx
 
Database user and administrator.pptx
Database user and administrator.pptxDatabase user and administrator.pptx
Database user and administrator.pptx
 
database language ppt.pptx
database language ppt.pptxdatabase language ppt.pptx
database language ppt.pptx
 
basic structure of SQL FINAL.pptx
basic structure of SQL FINAL.pptxbasic structure of SQL FINAL.pptx
basic structure of SQL FINAL.pptx
 
AGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptxAGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptx
 
CSS
CSSCSS
CSS
 
Greedy method
Greedy methodGreedy method
Greedy method
 
Heap sort
Heap sortHeap sort
Heap sort
 

Recently uploaded

Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 

Recently uploaded (20)

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 

fundamental relation algebra.pptx

  • 2. PREPARED BY Ms.K.Kannika -III-B.Sc - Information Technology Ms.R.Thirupurasundari -III-B.Sc-Information Technology UNDER THE GUIDANCE OF Mrs.P.Anusha M.Sc(IT).,M.Phil.,D.P.T.T.,(Ph.D)., Assistant professor, Department of Information Technology, Bon secours college for women, Thanjavur.
  • 3. RelAtional algebra :  Relational algebra is a procedural query language. It gives a step by step process to obtain the result of the query, it uses operators to perform queries  Relational algebra operation work on one or more relation to define another relation without changing the original relations.
  • 4. The fundamental operations of relational algebra are as follows :  Select  Project  Union  Set difference  Cartesian products  Rename
  • 5. Selection operation:  The select operation selects tuples that satisfy a given predicate  It is denoted sigma (σ)  Notation : σP(r) Where, σ is used for selection prediction r is used for relation P is used for propositional logic formula which may use connectors like : AND, OR and NOT. The relation can be use as relational operators like =, ≠, <=, >=, <, >
  • 6. Example : Table : Student Create table student(name varchar(255), age int, mark1 int, mark2 int) ; Insert into Student values(‘abirami’,’18’,’89’,’67’) ; Insert into student values(brindha, 18,79,97) ; Insert into student values(‘seetha’,’19’, ’81’,’84’); Select *from student ; Name Age Mark 1 Mark2 Abirami 18 89 67 Brindha 18 79 97 Seetha 19 81 84
  • 7. σ name =‘Brindha’(student) ; Name Age Mark1 Mark2 Brindha 18 79 97
  • 8. Project operation :  This operation shows the list of those attributes that we wish to appear in the result  Rest of the attributes are eliminated from the table  It is denoted by π  Notation : πA1, A2,.........,An (r)
  • 9. Example : πname, mark1(student) ; Name Mark1 Abirami 89 Brindha 79 Seetha 81
  • 10. Union operation :  Suppose there are two tuples R and S. The Union operation contains all the tuple that are either in R or S Or both in R & S  It eliminates the duplicate tuple  It is denoted by U  Notation: R U S  r U s = {t/t ∈ r or t ∈ s}
  • 11. A union operation must hold the following condition :  R and S must have the attribute of the same number  Duplicate tuple are eliminated automatically
  • 12. Example : Table : student Table : student1 Create table student1(name varchar (255), age int, mark1 int, mark2); Insert into student1 values('seetha‘, ’19’, ’85’,’ 84’) ; Insert into student1 values(‘gobi’, ’20’, ‘95’, ’66’) ; Insert into student1 values (‘revathi’, ’19’, ’85’, ’77’) ; select * from student1; Name Age Mark1 Mark2 Seetha 19 85 84 Gobi 20 95 66 Revathi 19 85 77
  • 13. π name, mark1(student) U πname, mark1(student1) ; Output : Name Mark 1 Abirami 89 Brindha 79 Seetha 81 Revathi 85 Gobi 95
  • 14. Set intersection :  Suppose there are two tuples R and S. The set intersection operation contain all tuples that are in both R & S  It is denoted by intersection ∩  Notation : R ∩ S
  • 15. Example : πname (student) ∩ πname(student) ; Name Seetha
  • 16. Set difference:  The result set of difference operation is tuples, which are present in one relation but are not in the second relation  It is denoted by - minus  Notation : R-S
  • 17. Example: πname(student) – πname(student1) ; OUTPUT: Name Abirami Brindha
  • 18. Cartesian products:  The cartesian product is used to combine each row in one table with each row in the other table it is also known as a cross product  It is denoted by X
  • 19. Example : Table : A Create table A( id_no int, age int, city varchar(255)) ; Insert into A values (’01’, ‘25‘, ‘chennai’) ; Insert into A values (’02’, ’24’, ‘Bangalore‘) ; Select * from A; Id_no Age City 01 25 Chennai 02 24 Bangalore
  • 20. Table B : Create table B(exam varchar(20) , mark1 int, mark2 int) ; Insert into B values ('CIA‘, ’64’, ’56’) ; Insert into B values(‘model’, ’69’, ’98’) ; Exam Mark1 Mark2 CIA 64 56 Model 69 98
  • 21. OUTPUT: A X B Id_no Age City Exam Mark1 Mark2 01 25 Chennai CIA 64 56 01 25 Chennai Model 69 98 02 24 Bangalore CIA 64 56 02 24 Bangalore Model 69 98
  • 22. Rename operation :  The result of relational algebra are also relations but without any name, the rename operation allows as to rename the output relation. ‘Rename’ operation is denoted with small Greek letter rho ρ  Notation: ρ × (E)  Where the result of the expression E is saved with name of x  We can use the rename operator the rename STUDENT relation to STUDENT 2  ρ(Student 2,student) ;
  • 23. FORMAL DEFINITION:  A General expression in the relational algebra is constructed out of smaller sub expressions.Let E1 and E2 be relational algebra expressions.Then the following are all relational algebra expressions:  E1 U E2 , E1 ∩ E2  E1 – E2  E1 X E2  (σ) p (E1) Where P is a predicate on attributes in E1.  Π S(E1) Where S is a list consisting of sum of the attributes in E1.  ρ x (E1) Where x is the new name for the result of E1.