SlideShare a Scribd company logo
1 of 21
Relational Algebra
Relational Algebra
• The relational algebra consists of a set of operators
that (speaking very loosely) allow us to derive
“new” relations from “old” ones.
• Each such operator takes one or more relations as
input and produces another relation as output.
Five operators:
– Union: 
– Intersection: 
– Difference: -
– Selection: s
– Projection: P
– Cartesian Product: 
– Rename : r
1. Union
2. Intersection
• It is used to derive common record
• R1  R2
3. Difference
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 > 400000 (Employee)
SSN Name Salary
1234545 John 200000
5423341 Smith 600000
4352342 Fred 500000
SSN Name Salary
5423341 Smith 600000
4352342 Fred 500000
Another selection
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
Example of Projection
Projection removes duplicates
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
Renaming
• Changes the schema, not the instance
• Notation: r B1,…,Bn (R)
• Example:
– rLastName, SocSocNo (Employee)
– Output schema:
Answer(LastName, SocSocNo)
Renaming Example
Employee
Name SSN
John 999999999
Tony 777777777
LastName SocSocNo
John 999999999
Tony 777777777
rLastName, SocSocNo (Employee)

More Related Content

Similar to 2. Relational Algebra.ppt

Relational operation final
Relational operation finalRelational operation final
Relational operation final
Student
 

Similar to 2. Relational Algebra.ppt (20)

Relational Algebra
Relational AlgebraRelational Algebra
Relational Algebra
 
Relational operation final
Relational operation finalRelational operation final
Relational operation final
 
hgvgvhbhv hvh h h h h h h h h h h h h .ppt
hgvgvhbhv hvh h h h h h h h h h h h h .ppthgvgvhbhv hvh h h h h h h h h h h h h .ppt
hgvgvhbhv hvh h h h h h h h h h h h h .ppt
 
354 ch6
354 ch6354 ch6
354 ch6
 
Lecture-3 Relational Algebra I.pptx
Lecture-3 Relational Algebra I.pptxLecture-3 Relational Algebra I.pptx
Lecture-3 Relational Algebra I.pptx
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
Relational algebra.pptx
Relational algebra.pptxRelational algebra.pptx
Relational algebra.pptx
 
DBMS CS3
DBMS CS3DBMS CS3
DBMS CS3
 
Chapter – 5 Relational Algebra.pdf
Chapter – 5 Relational Algebra.pdfChapter – 5 Relational Algebra.pdf
Chapter – 5 Relational Algebra.pdf
 
Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbms
 
14285 lecture2
14285 lecture214285 lecture2
14285 lecture2
 
Relation algebra (1).ppt
Relation algebra (1).pptRelation algebra (1).ppt
Relation algebra (1).ppt
 
chapter 5-Relational Algebra and calculus.ppt
chapter 5-Relational Algebra and calculus.pptchapter 5-Relational Algebra and calculus.ppt
chapter 5-Relational Algebra and calculus.ppt
 
3.2 SQL to -Relational Algebra.pdf
3.2  SQL to -Relational Algebra.pdf3.2  SQL to -Relational Algebra.pdf
3.2 SQL to -Relational Algebra.pdf
 
Dbms ii mca-ch5-ch6-relational algebra-2013
Dbms ii mca-ch5-ch6-relational algebra-2013Dbms ii mca-ch5-ch6-relational algebra-2013
Dbms ii mca-ch5-ch6-relational algebra-2013
 
Unit2 -DBMS.ppt with type of job operation
Unit2 -DBMS.ppt with type of job operationUnit2 -DBMS.ppt with type of job operation
Unit2 -DBMS.ppt with type of job operation
 
Relational algebra-and-relational-calculus
Relational algebra-and-relational-calculusRelational algebra-and-relational-calculus
Relational algebra-and-relational-calculus
 
DDL,DML,1stNF
DDL,DML,1stNFDDL,DML,1stNF
DDL,DML,1stNF
 
Query execution
Query executionQuery execution
Query execution
 
sfdfds
sfdfdssfdfds
sfdfds
 

More from SATHYABAMAMADHANKUMA (15)

1. Introduction to OS.ppt
1. Introduction to OS.ppt1. Introduction to OS.ppt
1. Introduction to OS.ppt
 
Client Side Scripting.pptx
Client Side Scripting.pptxClient Side Scripting.pptx
Client Side Scripting.pptx
 
1. UNIT - III.ppt
1. UNIT - III.ppt1. UNIT - III.ppt
1. UNIT - III.ppt
 
OK_Unit - I Multidisciplinary nature of environmental studies.ppt
OK_Unit - I Multidisciplinary nature of  environmental studies.pptOK_Unit - I Multidisciplinary nature of  environmental studies.ppt
OK_Unit - I Multidisciplinary nature of environmental studies.ppt
 
Unit - II - Eco Systems.ppt
Unit - II - Eco Systems.pptUnit - II - Eco Systems.ppt
Unit - II - Eco Systems.ppt
 
Unit - III Natural Resources.ppt
Unit - III Natural Resources.pptUnit - III Natural Resources.ppt
Unit - III Natural Resources.ppt
 
WP - Unit I.ppt
WP - Unit I.pptWP - Unit I.ppt
WP - Unit I.ppt
 
5-Recovery.ppt
5-Recovery.ppt5-Recovery.ppt
5-Recovery.ppt
 
6.RISK MANAGEMENT.pptx
6.RISK MANAGEMENT.pptx6.RISK MANAGEMENT.pptx
6.RISK MANAGEMENT.pptx
 
DBMS-CPD.ppt
DBMS-CPD.pptDBMS-CPD.ppt
DBMS-CPD.ppt
 
system prgramming - loaders-linkers.pdf
system prgramming - loaders-linkers.pdfsystem prgramming - loaders-linkers.pdf
system prgramming - loaders-linkers.pdf
 
SystemProgramming 2017.pdf
SystemProgramming 2017.pdfSystemProgramming 2017.pdf
SystemProgramming 2017.pdf
 
System-Programming 2018.pdf
System-Programming 2018.pdfSystem-Programming 2018.pdf
System-Programming 2018.pdf
 
ELNA6eCh21.ppt
ELNA6eCh21.pptELNA6eCh21.ppt
ELNA6eCh21.ppt
 
DBMS - Introduction.ppt
DBMS - Introduction.pptDBMS - Introduction.ppt
DBMS - Introduction.ppt
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
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"
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
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"
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
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
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

2. Relational Algebra.ppt

  • 2. Relational Algebra • The relational algebra consists of a set of operators that (speaking very loosely) allow us to derive “new” relations from “old” ones. • Each such operator takes one or more relations as input and produces another relation as output.
  • 3. Five operators: – Union:  – Intersection:  – Difference: - – Selection: s – Projection: P – Cartesian Product:  – Rename : r
  • 4.
  • 6.
  • 7. 2. Intersection • It is used to derive common record • R1  R2
  • 9.
  • 10. 3. Selection • Returns all tuples which satisfy a condition • Notation: sc(R) • Examples – sSalary > 40000 (Employee) – sname = “Smith” (Employee) • The condition c can be =, <, , >, , <>
  • 11. sSalary > 400000 (Employee) SSN Name Salary 1234545 John 200000 5423341 Smith 600000 4352342 Fred 500000 SSN Name Salary 5423341 Smith 600000 4352342 Fred 500000
  • 12.
  • 14. 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)
  • 15. P Name,Salary (Employee) SSN Name Salary 1234545 John 200000 5423341 John 600000 4352342 John 200000 Name Salary John 20000 John 60000
  • 18. 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
  • 19. 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
  • 20. Renaming • Changes the schema, not the instance • Notation: r B1,…,Bn (R) • Example: – rLastName, SocSocNo (Employee) – Output schema: Answer(LastName, SocSocNo)
  • 21. Renaming Example Employee Name SSN John 999999999 Tony 777777777 LastName SocSocNo John 999999999 Tony 777777777 rLastName, SocSocNo (Employee)