SlideShare a Scribd company logo
Relational Algebra
V.Deepa M.Sc.,M.Phil.,
Assistant Professor
Department of Computer Science
Sri Ramakrishna College of Arts and Science
Relational Algebra
• Five operators:
• Union: 
• Difference: -
• Selection: s
• Projection: P
• Cartesian Product: 
• Derived operators:
• Intersection, complement
• Joins (natural,equi-join, theta join, semi-join)
• Renaming: r
DBMS
• Database Management System or DBMS in short
refers to the technology of storing and retrieving
users data.
What is data and Information?
How relational algebra related to
DBMS?
• Relational algebra mainly provides theoretical
foundation for relational databases
Relation algebra (1).ppt
Introduction to Relation Algebra
• It was introduction by 1970
• By EF Code who is the father of DBMS.
• It is called procedural or formal query language.
Relational Algebra
• Frame for creating new relations from existing ones
• Its place in the big picture:
Declartive
query
language
Algebra
Implementation
SQL,
relational calculus
Relational algebra
Executable code
1. Union and 2. Difference
• R1  R2
• Example:
• ActiveEmployees  RetiredEmployees
• R1 – R2
• Example:
• AllEmployees -- RetiredEmployees
What about Intersection ?
• It is a derived operator
• R1  R2 = R1 – (R1 – R2)
• Also expressed as a join (will see later)
• Example
• UnionizedEmployees  RetiredEmployees
3. Selection
• Returns all tuples which satisfy a condition
• Notation: sc(R)
• Examples
• sSalary > 40000 (Employee)
• sname = “Smith” (Employee)
• The condition c can be =, <, , >, , <>
sSalary > 40000 (Employee)
SSN Name Salary
1234545 John 200000
5423341 Smith 600000
4352342 Fred 500000
SSN Name Salary
5423341 Smith 600000
4352342 Fred 500000
4. Projection
• Eliminates columns, then removes duplicates
• Notation: P A1,…,An (R)
• Example: project social-security number and names:
• P SSN, Name (Employee)
• Output schema: Answer(SSN, Name)
P Name,Salary (Employee)
SSN Name Salary
1234545 John 200000
5423341 John 600000
4352342 John 200000
Name Salary
John 20000
John 60000
5. Cartesian Product
• Each tuple in R1 with each tuple in R2
• Notation: R1  R2
• Example:
• Employee  Dependents
• Very rare in practice; mainly used to express joins
Cartesian Product Example
Employee
Name SSN
John 999999999
Tony 777777777
Dependents
EmployeeSSN Dname
999999999 Emily
777777777 Joe
Employee x Dependents
Name SSN EmployeeSSN Dname
John 999999999 999999999 Emily
John 999999999 777777777 Joe
Tony 777777777 999999999 Emily
Tony 777777777 777777777 Joe
Relational Algebra
• Five operators:
• Union: 
• Difference: -
• Selection: s
• Projection: P
• Cartesian Product: 
• Derived or auxiliary operators:
• Intersection, complement
• Joins (natural,equi-join, theta join, semi-join)
• Renaming: r
Operations on Bags
A bag = a set with repeated elements
All operations need to be defined carefully on bags
• {a,b,b,c}{a,b,b,b,e,f,f}={a,a,b,b,b,b,b,c,e,f,f}
• {a,b,b,b,c,c} – {b,c,c,c,d} = {a,b,b,c,d}
• sC(R): preserve the number of occurrences
• PA(R): no duplicate elimination
• Cartesian product, join: no duplicate elimination
Important ! Relational Engines work on bags, not sets !
Joins
• Joins is a combinatio of Cartesian product by a
selection process.
• Inner Joins:
Theta join
EQUI join
Natural join
• Outer joins:
Left outer join
Right outer join
Full outer join
• Also known as conditional join.
• Used when you want to join two or more relation
based on some conditions.
• Is a special case of conditional join.
• When a theta join uses only equivalence condition, it
become a equi join
• As value of two attributes will be equal in result of
equaijoin, only one attribute will be appeared in
result.
Thank you

More Related Content

PPT
Relational Algebra.ppt
PPTX
lecture22.pptx relational Algebra basics types
PPT
hgvgvhbhv hvh h h h h h h h h h h h h .ppt
PPT
Relational Algebra(Part1) (1) in Maths.ppt
PPT
2. Relational Algebra.ppt
PPTX
Module 2_Relational Algebra.pptx
PPTX
Lecture-3 Relational Algebra I.pptx
PPTX
3._Relational_Algebra.pptx:Basics of relation algebra
Relational Algebra.ppt
lecture22.pptx relational Algebra basics types
hgvgvhbhv hvh h h h h h h h h h h h h .ppt
Relational Algebra(Part1) (1) in Maths.ppt
2. Relational Algebra.ppt
Module 2_Relational Algebra.pptx
Lecture-3 Relational Algebra I.pptx
3._Relational_Algebra.pptx:Basics of relation algebra

Similar to Relation algebra (1).ppt (20)

PPTX
Relational Algebra in DBMS 2025 power point
PDF
MOD2-DBMS.pdf
PDF
Dbms 11: Relational Algebra
PPTX
PDF
Relational algebra in dbms
PPTX
Relational algebra dbms (2130703) - 160920107003
PPT
Relational algebra operations
PDF
Cs501 rel algebra
PPTX
Relational algebra
PDF
Unit_3.pdf
PPTX
Relational operation final
PPT
relalgebraasssssssssssssssssssssssss.ppt
PPTX
Presentation of rdbms2
PPT
Relational Algebra1.ppt
PPT
PPTX
Query and optimizing operating system.pptx
PPT
Relational algebra in dbms
PDF
Chapter – 5 Relational Algebra.pdf
PDF
Relational model
PPTX
lecture 4 Relational Algebra my sql work
Relational Algebra in DBMS 2025 power point
MOD2-DBMS.pdf
Dbms 11: Relational Algebra
Relational algebra in dbms
Relational algebra dbms (2130703) - 160920107003
Relational algebra operations
Cs501 rel algebra
Relational algebra
Unit_3.pdf
Relational operation final
relalgebraasssssssssssssssssssssssss.ppt
Presentation of rdbms2
Relational Algebra1.ppt
Query and optimizing operating system.pptx
Relational algebra in dbms
Chapter – 5 Relational Algebra.pdf
Relational model
lecture 4 Relational Algebra my sql work
Ad

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Chapter 5: Probability Theory and Statistics
PDF
DP Operators-handbook-extract for the Mautical Institute
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
A Presentation on Touch Screen Technology
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Zenith AI: Advanced Artificial Intelligence
Encapsulation_ Review paper, used for researhc scholars
Chapter 5: Probability Theory and Statistics
DP Operators-handbook-extract for the Mautical Institute
OMC Textile Division Presentation 2021.pptx
Assigned Numbers - 2025 - Bluetooth® Document
A comparative analysis of optical character recognition models for extracting...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
A novel scalable deep ensemble learning framework for big data classification...
Web App vs Mobile App What Should You Build First.pdf
Tartificialntelligence_presentation.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
A comparative study of natural language inference in Swahili using monolingua...
Group 1 Presentation -Planning and Decision Making .pptx
Enhancing emotion recognition model for a student engagement use case through...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
A Presentation on Touch Screen Technology
Univ-Connecticut-ChatGPT-Presentaion.pdf
Zenith AI: Advanced Artificial Intelligence
Ad

Relation algebra (1).ppt

  • 1. Relational Algebra V.Deepa M.Sc.,M.Phil., Assistant Professor Department of Computer Science Sri Ramakrishna College of Arts and Science
  • 2. Relational Algebra • Five operators: • Union:  • Difference: - • Selection: s • Projection: P • Cartesian Product:  • Derived operators: • Intersection, complement • Joins (natural,equi-join, theta join, semi-join) • Renaming: r
  • 3. DBMS • Database Management System or DBMS in short refers to the technology of storing and retrieving users data.
  • 4. What is data and Information?
  • 5. How relational algebra related to DBMS? • Relational algebra mainly provides theoretical foundation for relational databases
  • 7. Introduction to Relation Algebra • It was introduction by 1970 • By EF Code who is the father of DBMS. • It is called procedural or formal query language.
  • 8. Relational Algebra • Frame for creating new relations from existing ones • Its place in the big picture: Declartive query language Algebra Implementation SQL, relational calculus Relational algebra Executable code
  • 9. 1. Union and 2. Difference • R1  R2 • Example: • ActiveEmployees  RetiredEmployees • R1 – R2 • Example: • AllEmployees -- RetiredEmployees
  • 10. What about Intersection ? • It is a derived operator • R1  R2 = R1 – (R1 – R2) • Also expressed as a join (will see later) • Example • UnionizedEmployees  RetiredEmployees
  • 11. 3. Selection • Returns all tuples which satisfy a condition • Notation: sc(R) • Examples • sSalary > 40000 (Employee) • sname = “Smith” (Employee) • The condition c can be =, <, , >, , <>
  • 12. sSalary > 40000 (Employee) SSN Name Salary 1234545 John 200000 5423341 Smith 600000 4352342 Fred 500000 SSN Name Salary 5423341 Smith 600000 4352342 Fred 500000
  • 13. 4. Projection • Eliminates columns, then removes duplicates • Notation: P A1,…,An (R) • Example: project social-security number and names: • P SSN, Name (Employee) • Output schema: Answer(SSN, Name)
  • 14. P Name,Salary (Employee) SSN Name Salary 1234545 John 200000 5423341 John 600000 4352342 John 200000 Name Salary John 20000 John 60000
  • 15. 5. Cartesian Product • Each tuple in R1 with each tuple in R2 • Notation: R1  R2 • Example: • Employee  Dependents • Very rare in practice; mainly used to express joins
  • 16. Cartesian Product Example Employee Name SSN John 999999999 Tony 777777777 Dependents EmployeeSSN Dname 999999999 Emily 777777777 Joe Employee x Dependents Name SSN EmployeeSSN Dname John 999999999 999999999 Emily John 999999999 777777777 Joe Tony 777777777 999999999 Emily Tony 777777777 777777777 Joe
  • 17. Relational Algebra • Five operators: • Union:  • Difference: - • Selection: s • Projection: P • Cartesian Product:  • Derived or auxiliary operators: • Intersection, complement • Joins (natural,equi-join, theta join, semi-join) • Renaming: r
  • 18. Operations on Bags A bag = a set with repeated elements All operations need to be defined carefully on bags • {a,b,b,c}{a,b,b,b,e,f,f}={a,a,b,b,b,b,b,c,e,f,f} • {a,b,b,b,c,c} – {b,c,c,c,d} = {a,b,b,c,d} • sC(R): preserve the number of occurrences • PA(R): no duplicate elimination • Cartesian product, join: no duplicate elimination Important ! Relational Engines work on bags, not sets !
  • 19. Joins • Joins is a combinatio of Cartesian product by a selection process. • Inner Joins: Theta join EQUI join Natural join • Outer joins: Left outer join Right outer join Full outer join
  • 20. • Also known as conditional join. • Used when you want to join two or more relation based on some conditions.
  • 21. • Is a special case of conditional join. • When a theta join uses only equivalence condition, it become a equi join • As value of two attributes will be equal in result of equaijoin, only one attribute will be appeared in result.