SlideShare a Scribd company logo
Database Management System (DBMS)
Sanjivani Rural Education Society’s
Sanjivani College of Engineering, Kopargaon-423603
(An Autonomous Institute Affiliated to Savitribai Phule Pune University, Pune)
NACC ‘A’ Grade Accredited, ISO 9001:2015 Certified
Department of Information Technology
(NBA Accredited)
SY IT
Prof. R. N. Kankrale
Assistant Professor
UNIT-II
RELATIONAL ALGEBRA
Relational Algebra
• Relational Algebra is a procedural query language which takes a
relation as an input and generates a relation as an output.
• Following are the important characteristics of relational operators-
Relational Operators always work on one or more relational tables.
Relational Operators always produce another relational table.
The table produced by a relational operator has all the properties of a
relational model.
DBMS – Unit-II Relational Algebra Department of Information Technology
Relational Algebra Operators-
DBMS – Unit-II Relational Algebra Department of Information Technology
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
Selection Operator-
•Selection Operator (σ) is a unary operator in relational algebra that
performs a selection operation.
•It selects those rows or tuples from the relation that satisfies the selection
condition.
Syntax-
σ<selection_condition>(R)
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
Examples-
• Select tuples from a relation “Books” where subject is “database”
σsubject = “database” (Books)
• Select tuples from a relation “Books” where subject is “database” and price is
“450”.
σsubject = “database” price = “450”
∧ (Books)
• Select tuples from a relation “Books” where subject is “database” and price is
“450” or have a publication year after 2010
σsubject = “database” price = “450” year >”2010″
∧ ∨ (Books)
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
Important Points-
Point-01:
We may use logical operators like , , ! and relational operators like = , ≠ ,
∧ ∨
> , < , <= , >= with the selection condition.
Point-02:
•Selection operator only selects the required tuples according to the selection
condition.
•It does not display the selected tuples.
•To display the selected tuples, projection operator is used.
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
Point-03:
•Selection operator always selects the entire tuple. It can not
select a section or part of a tuple.
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
Projection Operator-
• Projection Operator (π) is a unary operator in relational algebra that
performs a projection operation.
• It displays the columns of a relation or table based on the specified
attributes.
Syntax-
π<attribute list>(R)
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
Example-Consider the following Student relation-
ID Name Subject Age
100 Ashish Maths 19
200 Rahul Science 20
300 Naina Physics 20
400 Sameer Chemistry 21
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
Example-Consider the following Student relation-
Result for Query
πID , Name(Student)-
ID Name
100 Ashish
200 Rahul
300 Naina
400 Sameer
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
Important Points-Projection Operator-
Point-01:
•The degree of output relation (number of columns present) is equal
to the number of attributes mentioned in the attribute list.
Point-02:
•Projection operator automatically removes all the duplicates while
projecting the output relation.
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
Point-03:
•Selection Operator performs horizontal partitioning of the
relation.
•Projection operator performs vertical partitioning of the relation.
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
Point-04:
•There is only one difference between projection operator of relational algebra
and SELECT operation of SQL.
•Projection operator does not allow duplicates while SELECT operation allows
duplicates.
•To avoid duplicates in SQL, we use “distinct” keyword and write SELECT
distinct.
•Thus, projection operator of relational algebra is equivalent to SELECT
operation of SQL.
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
Set Theory Operators-
1.Union Operator ( )
∪
2.Intersection Operator (∩)
3.Difference Operator (-)
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
1.Union Operator ( )
∪
Let R and S be two relations.
Then-
•R S is the set of all tuples belonging to either R or S or both.
∪
•In R S, duplicates are automatically removed.
∪
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
Union Operator ( ):-
∪
Example- Consider the following two relations R and S-
ID Name Subject
100 Ankit English
200 Pooja Maths
300 Komal Science
Relation R
ID Name Subject
100 Ankit English
400 Kajol French
ID Name Subject
100 Ankit English
200 Pooja Maths
300 Komal Science
400 Kajol French
Relation R S
∪
Relation S
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
. Intersection Operator ( )-
∩
Let R and S be two relations.
Then-
•R ∩ S is the set of all tuples belonging to both R and S.
•In R ∩ S, duplicates are automatically removed.
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
. Intersection Operator ( )-
∩
Example-Consider the following two relations R and S-
ID Name Subject
100 Ankit English
200 Pooja Maths
300 Komal Science
Relation R
ID Name Subject
100 Ankit English
400 Kajol French
100 Ankit English
Relation S
ID Name Subject
100 Ankit English
Relation R S
∩
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
3. Difference Operator (-)-
Let R and S be two relations.
Then-
•R – S is the set of all tuples belonging to R and not to S.
•In R – S, duplicates are automatically removed.
Relational Algebra
DBMS – Unit-II Relational Algebra Department of Information Technology
3. Difference Operator (-)-
Example-Consider the following two relations R and S-
ID Name Subject
100 Ankit English
200 Pooja Maths
300 Komal Science
Relation R
ID Name Subject
100 Ankit English
400 Kajol French
Relation S
ID Name Subject
200 Pooja Maths
300 Komal Science
Relation R – S
CARTESIAN PRODUCT
• A Cartesian Join or CROSS JOIN returns the Cartesian product of two tables, meaning
each row from the first table is combined with every row from the second table. This type
of join does not require any specific condition or matching column between the two
tables.
References
• https://www.gatevidyalay.com/relational-algebra-relational-algebra-i
n-dbms/
DBMS – Unit-II Relational Algebra Department of Information Technology

More Related Content

PPT
UNIT 2 relational algebra and Structured Query Language
PPT
relational algebra and it's implementation
PPTX
Relational algebra
PDF
Database management system lecture note.
PPTX
Chapter-6 Relational Algebra
PPTX
Relational Model,relational calulus.pptx
PPTX
Relational operation final
PPT
Relational Algebra
UNIT 2 relational algebra and Structured Query Language
relational algebra and it's implementation
Relational algebra
Database management system lecture note.
Chapter-6 Relational Algebra
Relational Model,relational calulus.pptx
Relational operation final
Relational Algebra

Similar to UNIT 2 relational algebra and Structured Query Language (20)

PPTX
Info_Management_report-1.pptx
PPTX
316_16SCCCS4_2020052505222431.pptdatabasex
PPTX
Introduction to MATLAB
PPTX
Relational Algebra in DBMS power ppoint pesenetation
PDF
Relational algebra in dbms
PDF
Relational Database and Relational Algebra
PPTX
DBMS - Relational Model, Relational Table
PPTX
C sharp part 001
PPTX
Verilog operators.pptx
PPTX
7-Aljabar-Relasional-dan-Query-Processing.pptx
PPTX
RQP reverse query processing it's application 2011.pptx
PPTX
Relational algebra calculus
PPTX
Relational Algebra.Pptxjejejjdjdh jsjsjd
PPTX
PDF
IT-243-L13-14-1. pdf
PPTX
Understanding Operators in R Programming
PDF
Relational_Algebra_Calculus Operations.pdf
PPTX
DBMS - Relational Algebra
PPT
Normmmalizzarion.ppt
PPTX
Relational Calculus
Info_Management_report-1.pptx
316_16SCCCS4_2020052505222431.pptdatabasex
Introduction to MATLAB
Relational Algebra in DBMS power ppoint pesenetation
Relational algebra in dbms
Relational Database and Relational Algebra
DBMS - Relational Model, Relational Table
C sharp part 001
Verilog operators.pptx
7-Aljabar-Relasional-dan-Query-Processing.pptx
RQP reverse query processing it's application 2011.pptx
Relational algebra calculus
Relational Algebra.Pptxjejejjdjdh jsjsjd
IT-243-L13-14-1. pdf
Understanding Operators in R Programming
Relational_Algebra_Calculus Operations.pdf
DBMS - Relational Algebra
Normmmalizzarion.ppt
Relational Calculus
Ad

More from RajendraKankrale1 (7)

PPTX
5.Transaction Management and concurrency Control
PPTX
PL_SQL, Trigger, Cursor, Stored procedure ,function
PPT
UNIT 1 ER Model 2025 -Entity Relationship (ER) Diagram
PPTX
HADOOP ECO SYSTEM Pig: Introduction to PIG, Execution Modes of Pig, Comp...
PPTX
INTRODUCTION TO APACHE HADOOP AND MAPREDUCE
PPTX
Unit2_Regression, ADVANCED ANALYTICAL THEORY AND METHODS USING PYTHON
PPTX
Unit-I_Big data life cycle.pptx, sources of Big Data
5.Transaction Management and concurrency Control
PL_SQL, Trigger, Cursor, Stored procedure ,function
UNIT 1 ER Model 2025 -Entity Relationship (ER) Diagram
HADOOP ECO SYSTEM Pig: Introduction to PIG, Execution Modes of Pig, Comp...
INTRODUCTION TO APACHE HADOOP AND MAPREDUCE
Unit2_Regression, ADVANCED ANALYTICAL THEORY AND METHODS USING PYTHON
Unit-I_Big data life cycle.pptx, sources of Big Data
Ad

Recently uploaded (20)

PDF
01-Introduction-to-Information-Management.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
RMMM.pdf make it easy to upload and study
PDF
Complications of Minimal Access Surgery at WLH
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
01-Introduction-to-Information-Management.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Computing-Curriculum for Schools in Ghana
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
VCE English Exam - Section C Student Revision Booklet
O7-L3 Supply Chain Operations - ICLT Program
102 student loan defaulters named and shamed – Is someone you know on the list?
Anesthesia in Laparoscopic Surgery in India
human mycosis Human fungal infections are called human mycosis..pptx
RMMM.pdf make it easy to upload and study
Complications of Minimal Access Surgery at WLH
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
FourierSeries-QuestionsWithAnswers(Part-A).pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Final Presentation General Medicine 03-08-2024.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
202450812 BayCHI UCSC-SV 20250812 v17.pptx

UNIT 2 relational algebra and Structured Query Language

  • 1. Database Management System (DBMS) Sanjivani Rural Education Society’s Sanjivani College of Engineering, Kopargaon-423603 (An Autonomous Institute Affiliated to Savitribai Phule Pune University, Pune) NACC ‘A’ Grade Accredited, ISO 9001:2015 Certified Department of Information Technology (NBA Accredited) SY IT Prof. R. N. Kankrale Assistant Professor
  • 3. Relational Algebra • Relational Algebra is a procedural query language which takes a relation as an input and generates a relation as an output. • Following are the important characteristics of relational operators- Relational Operators always work on one or more relational tables. Relational Operators always produce another relational table. The table produced by a relational operator has all the properties of a relational model. DBMS – Unit-II Relational Algebra Department of Information Technology
  • 4. Relational Algebra Operators- DBMS – Unit-II Relational Algebra Department of Information Technology
  • 5. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology Selection Operator- •Selection Operator (σ) is a unary operator in relational algebra that performs a selection operation. •It selects those rows or tuples from the relation that satisfies the selection condition. Syntax- σ<selection_condition>(R)
  • 6. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology Examples- • Select tuples from a relation “Books” where subject is “database” σsubject = “database” (Books) • Select tuples from a relation “Books” where subject is “database” and price is “450”. σsubject = “database” price = “450” ∧ (Books) • Select tuples from a relation “Books” where subject is “database” and price is “450” or have a publication year after 2010 σsubject = “database” price = “450” year >”2010″ ∧ ∨ (Books)
  • 7. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology Important Points- Point-01: We may use logical operators like , , ! and relational operators like = , ≠ , ∧ ∨ > , < , <= , >= with the selection condition. Point-02: •Selection operator only selects the required tuples according to the selection condition. •It does not display the selected tuples. •To display the selected tuples, projection operator is used.
  • 8. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology Point-03: •Selection operator always selects the entire tuple. It can not select a section or part of a tuple.
  • 9. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology Projection Operator- • Projection Operator (π) is a unary operator in relational algebra that performs a projection operation. • It displays the columns of a relation or table based on the specified attributes. Syntax- π<attribute list>(R)
  • 10. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology Example-Consider the following Student relation- ID Name Subject Age 100 Ashish Maths 19 200 Rahul Science 20 300 Naina Physics 20 400 Sameer Chemistry 21
  • 11. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology Example-Consider the following Student relation- Result for Query πID , Name(Student)- ID Name 100 Ashish 200 Rahul 300 Naina 400 Sameer
  • 12. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology Important Points-Projection Operator- Point-01: •The degree of output relation (number of columns present) is equal to the number of attributes mentioned in the attribute list. Point-02: •Projection operator automatically removes all the duplicates while projecting the output relation.
  • 13. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology Point-03: •Selection Operator performs horizontal partitioning of the relation. •Projection operator performs vertical partitioning of the relation.
  • 14. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology Point-04: •There is only one difference between projection operator of relational algebra and SELECT operation of SQL. •Projection operator does not allow duplicates while SELECT operation allows duplicates. •To avoid duplicates in SQL, we use “distinct” keyword and write SELECT distinct. •Thus, projection operator of relational algebra is equivalent to SELECT operation of SQL.
  • 15. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology Set Theory Operators- 1.Union Operator ( ) ∪ 2.Intersection Operator (∩) 3.Difference Operator (-)
  • 16. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology 1.Union Operator ( ) ∪ Let R and S be two relations. Then- •R S is the set of all tuples belonging to either R or S or both. ∪ •In R S, duplicates are automatically removed. ∪
  • 17. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology Union Operator ( ):- ∪ Example- Consider the following two relations R and S- ID Name Subject 100 Ankit English 200 Pooja Maths 300 Komal Science Relation R ID Name Subject 100 Ankit English 400 Kajol French ID Name Subject 100 Ankit English 200 Pooja Maths 300 Komal Science 400 Kajol French Relation R S ∪ Relation S
  • 18. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology . Intersection Operator ( )- ∩ Let R and S be two relations. Then- •R ∩ S is the set of all tuples belonging to both R and S. •In R ∩ S, duplicates are automatically removed.
  • 19. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology . Intersection Operator ( )- ∩ Example-Consider the following two relations R and S- ID Name Subject 100 Ankit English 200 Pooja Maths 300 Komal Science Relation R ID Name Subject 100 Ankit English 400 Kajol French 100 Ankit English Relation S ID Name Subject 100 Ankit English Relation R S ∩
  • 20. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology 3. Difference Operator (-)- Let R and S be two relations. Then- •R – S is the set of all tuples belonging to R and not to S. •In R – S, duplicates are automatically removed.
  • 21. Relational Algebra DBMS – Unit-II Relational Algebra Department of Information Technology 3. Difference Operator (-)- Example-Consider the following two relations R and S- ID Name Subject 100 Ankit English 200 Pooja Maths 300 Komal Science Relation R ID Name Subject 100 Ankit English 400 Kajol French Relation S ID Name Subject 200 Pooja Maths 300 Komal Science Relation R – S
  • 22. CARTESIAN PRODUCT • A Cartesian Join or CROSS JOIN returns the Cartesian product of two tables, meaning each row from the first table is combined with every row from the second table. This type of join does not require any specific condition or matching column between the two tables.