SlideShare a Scribd company logo
1 of 20
Tuesday, November 10, 2015 1CSE&S
Relational Algebra
operation
Nizam Khan Kakar
12CS-17
Tuesday, November 10, 2015 2CSE&S
Objectives of the Topic.Objectives of the Topic.
1. Introduction to Relational Algebra.
2. What is Relational Algebra?
3 What is Algebra Operation?
3.Basic Operation of Relation algebra.
i. Selection (A α alpha)
ii. Projection (Π π pi)
iii. Cross-product (X χ chi)
iv. Union
v. Intersection
vi. Set-difference
S S1 2∪
S S1 2∩
S S1 2−
Tuesday, November 10, 2015 3CSE&S
Introduction to Relational Algebra
Introduced by E. F.
Codd in 1970.
Codd proposed such
an algebra as a basis
for database query
languages.
Tuesday, November 10, 2015 4CSE&S
What is Relational Algebra?
Relational Algebra is formal description of
how relational database operates.
It is a procedural query language, i.e. user
must define both “how” and “what” to
retrieve.
It consists of a set of operators that
consume either one or two relations as
input. An operator produces one relation
as its output.
Tuesday, November 10, 2015 5CSE&S
What is Algebra Operations?
Unary Operations - operate on one
relation. These include select, project
and rename operators.
Binary Operations - operate on pairs
of relations. These include union, set
difference, division, cartesian product,
equality join, natural join, join and
semi-join operators.
Tuesday, November 10, 2015 6CSE&S
Select Operator (б )
The Select operator selects tuples that satisfies a
predicate; e.g. retrieve the employees whose
salary is 30,000
б Salary = 30,000 (Employee)
Conditions in Selection:
Simple Condition: (attribute)(comparison)(attribute)
(attribute)(comparison)(constant)
Comparison: =,≠,≤,≥,<,>
Condition: combination of simple conditions with
AND, OR, NOT
Tuesday, November 10, 2015 7CSE&S
Select Operator Example
Name Age Weight
Nizam 34 80
Sana 28 64
Anwar 29 70
Hamal 54 54
Asad 34 80
Name Age Weight
Nizam 34 80
Hamal 54 54
Asad 34 80
Person бAge≥34(Person)
Name Age Weight
Hamal 54 54
бAge=Weight(Person)
Tuesday, November 10, 2015 8CSE&S
Project Operator (∏)
Project (∏) retrieves a column. Duplication
is not permitted.
e.g., name of employees:
∏ name(Employee)
e.g., name of employees earning more
than 80,000:
∏ name(бSalary>80,000(Employee))
Tuesday, November 10, 2015 9CSE&S
Project Operator Example
Name Age Salary
Zarak 34 80,000
Fida 28 90,000
Kabeer 29 70,000
Imran 54 54,280
Salma 34 40,000
Name
Zarak
Fida
Kabeer
Imran
Salma
Employee
∏ name(Employee)
Tuesday, November 10, 2015 10CSE&S
Project Operator Example
Name Age Salary
Zarak 34 80,000
Fida 28 90,000
Kabeer 29 70,000
Imran 54 54,280
Salma 34 40,000
Name
Fida
Employee бSalary>80,000(Employee)
Name Age Salary
Fida 28 90,000
∏ name(бSalary>80,000(Employee))
Tuesday, November 10, 2015 11CSE&S
Cartesian Product (X)
In mathematics, it is a set of all pairs of
elements (x, y) that can be constructed
from given sets, X and Y, such that x
belongs to X and y to Y.
It defines a relation that is the
concatenation of every tuple of relation R
with every tuple of relation S.
Tuesday, November 10, 2015 12CSE&S
Cartesian Product Example
Name Age Weight
Nizam 34 80
Sana 28 64
Anwar 29 70
City
Loralai
Khuzdar
Person City
Person X City
Name Age Weight City
Nizam 34 80 Loralai
Sana 28 64 Loralai
Anwar 29 70 Loralai
Nizam 34 80 Khuzdar
Sana 28 64 Khuzdar
Anwar 29 70 Khuzdar
Tuesday, November 10, 2015 13CSE&S
Union Operator (U)
The union operation is denoted U as in set
theory. It returns the union (set union) of
two compatible relations.
For a union operation r U s to be legal, we
require that,
r and s must have the same number of
attributes.
The domains of the corresponding
attributes must be the same.
As in all set operations, duplicates are
eliminated.
Tuesday, November 10, 2015 14CSE&S
Union Operator Example
F Name L Name
Ahmad Ashraf
Sadam Arif
Niaz Shah
Asif Wajid
Ali Qabool
F Name L Name
Sadam Arif
Kamal Noor
Asif Wajid
Salman Khan
Shabeer Ali
Student
Professor
F Name L Name
Ahmad Ashraf
Sadam Arif
Niaz Shah
Asif Wajid
Ali Qabool
Kamal Noor
Salman Khan
Shabeer Ali
Student U Professor
Tuesday, November 10, 2015
15CSE&S
Intersection Operator (∩)
Denoted as ∩ . For relations R and S, intersection
is R ∩ S.
Defines a relation consisting of the set of all
tuples that are in both R and S.
R and S must be union-compatible.
Expressed using basic operations:
R ∩ S = R – (R – S)
Tuesday, November 10, 2015 16CSE&S
Intersection Operator Example
F Name L Name
Ahmad Ashraf
Sadam Arif
Niaz Shah
Asif Wajid
Ali Qabool
F Name L Name
Sadam Arif
Kamal Noor
Asif Wajid
Salman Khan
Shabeer Ali
Student
Professor
F Name L Name
Sadam Arif
Asif Wajid
Student ∩ Professor
Tuesday, November 10, 2015 17CSE&S
Set Difference Operator (–)
For relations R and S,
Set difference R - S, defines a relation
consisting of the tuples that are in relation
R, but not in S.
Set difference S – R, defines a relation
consisting of the tuples that are in relation
S, but not in R.
Tuesday, November 10, 2015 18CSE&S
Set Difference Operator Example
F Name L Name
Ahmad Ashraf
Sadam Arif
Niaz Shah
Asif Wajid
Ali Qabool
F Name L Name
Sadam Arif
Kamal Noor
Asif Wajid
Salman Khan
Shabeer Ali
Student Professor
F Name L Name
Ahmad Ashraf
Niaz Shah
Ali Qabool
Student - Professor
F Name L Name
Kamal Noor
Salman Khan
Shabeer Ali
Professor - Student
Tuesday, November 10, 2015 19CSE&S
Tuesday, November 10, 2015 20CSE&S

More Related Content

Recently uploaded

High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 

Recently uploaded (20)

High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Relational Algibra operation

  • 1. Tuesday, November 10, 2015 1CSE&S
  • 2. Relational Algebra operation Nizam Khan Kakar 12CS-17 Tuesday, November 10, 2015 2CSE&S
  • 3. Objectives of the Topic.Objectives of the Topic. 1. Introduction to Relational Algebra. 2. What is Relational Algebra? 3 What is Algebra Operation? 3.Basic Operation of Relation algebra. i. Selection (A α alpha) ii. Projection (Π π pi) iii. Cross-product (X χ chi) iv. Union v. Intersection vi. Set-difference S S1 2∪ S S1 2∩ S S1 2− Tuesday, November 10, 2015 3CSE&S
  • 4. Introduction to Relational Algebra Introduced by E. F. Codd in 1970. Codd proposed such an algebra as a basis for database query languages. Tuesday, November 10, 2015 4CSE&S
  • 5. What is Relational Algebra? Relational Algebra is formal description of how relational database operates. It is a procedural query language, i.e. user must define both “how” and “what” to retrieve. It consists of a set of operators that consume either one or two relations as input. An operator produces one relation as its output. Tuesday, November 10, 2015 5CSE&S
  • 6. What is Algebra Operations? Unary Operations - operate on one relation. These include select, project and rename operators. Binary Operations - operate on pairs of relations. These include union, set difference, division, cartesian product, equality join, natural join, join and semi-join operators. Tuesday, November 10, 2015 6CSE&S
  • 7. Select Operator (б ) The Select operator selects tuples that satisfies a predicate; e.g. retrieve the employees whose salary is 30,000 б Salary = 30,000 (Employee) Conditions in Selection: Simple Condition: (attribute)(comparison)(attribute) (attribute)(comparison)(constant) Comparison: =,≠,≤,≥,<,> Condition: combination of simple conditions with AND, OR, NOT Tuesday, November 10, 2015 7CSE&S
  • 8. Select Operator Example Name Age Weight Nizam 34 80 Sana 28 64 Anwar 29 70 Hamal 54 54 Asad 34 80 Name Age Weight Nizam 34 80 Hamal 54 54 Asad 34 80 Person бAge≥34(Person) Name Age Weight Hamal 54 54 бAge=Weight(Person) Tuesday, November 10, 2015 8CSE&S
  • 9. Project Operator (∏) Project (∏) retrieves a column. Duplication is not permitted. e.g., name of employees: ∏ name(Employee) e.g., name of employees earning more than 80,000: ∏ name(бSalary>80,000(Employee)) Tuesday, November 10, 2015 9CSE&S
  • 10. Project Operator Example Name Age Salary Zarak 34 80,000 Fida 28 90,000 Kabeer 29 70,000 Imran 54 54,280 Salma 34 40,000 Name Zarak Fida Kabeer Imran Salma Employee ∏ name(Employee) Tuesday, November 10, 2015 10CSE&S
  • 11. Project Operator Example Name Age Salary Zarak 34 80,000 Fida 28 90,000 Kabeer 29 70,000 Imran 54 54,280 Salma 34 40,000 Name Fida Employee бSalary>80,000(Employee) Name Age Salary Fida 28 90,000 ∏ name(бSalary>80,000(Employee)) Tuesday, November 10, 2015 11CSE&S
  • 12. Cartesian Product (X) In mathematics, it is a set of all pairs of elements (x, y) that can be constructed from given sets, X and Y, such that x belongs to X and y to Y. It defines a relation that is the concatenation of every tuple of relation R with every tuple of relation S. Tuesday, November 10, 2015 12CSE&S
  • 13. Cartesian Product Example Name Age Weight Nizam 34 80 Sana 28 64 Anwar 29 70 City Loralai Khuzdar Person City Person X City Name Age Weight City Nizam 34 80 Loralai Sana 28 64 Loralai Anwar 29 70 Loralai Nizam 34 80 Khuzdar Sana 28 64 Khuzdar Anwar 29 70 Khuzdar Tuesday, November 10, 2015 13CSE&S
  • 14. Union Operator (U) The union operation is denoted U as in set theory. It returns the union (set union) of two compatible relations. For a union operation r U s to be legal, we require that, r and s must have the same number of attributes. The domains of the corresponding attributes must be the same. As in all set operations, duplicates are eliminated. Tuesday, November 10, 2015 14CSE&S
  • 15. Union Operator Example F Name L Name Ahmad Ashraf Sadam Arif Niaz Shah Asif Wajid Ali Qabool F Name L Name Sadam Arif Kamal Noor Asif Wajid Salman Khan Shabeer Ali Student Professor F Name L Name Ahmad Ashraf Sadam Arif Niaz Shah Asif Wajid Ali Qabool Kamal Noor Salman Khan Shabeer Ali Student U Professor Tuesday, November 10, 2015 15CSE&S
  • 16. Intersection Operator (∩) Denoted as ∩ . For relations R and S, intersection is R ∩ S. Defines a relation consisting of the set of all tuples that are in both R and S. R and S must be union-compatible. Expressed using basic operations: R ∩ S = R – (R – S) Tuesday, November 10, 2015 16CSE&S
  • 17. Intersection Operator Example F Name L Name Ahmad Ashraf Sadam Arif Niaz Shah Asif Wajid Ali Qabool F Name L Name Sadam Arif Kamal Noor Asif Wajid Salman Khan Shabeer Ali Student Professor F Name L Name Sadam Arif Asif Wajid Student ∩ Professor Tuesday, November 10, 2015 17CSE&S
  • 18. Set Difference Operator (–) For relations R and S, Set difference R - S, defines a relation consisting of the tuples that are in relation R, but not in S. Set difference S – R, defines a relation consisting of the tuples that are in relation S, but not in R. Tuesday, November 10, 2015 18CSE&S
  • 19. Set Difference Operator Example F Name L Name Ahmad Ashraf Sadam Arif Niaz Shah Asif Wajid Ali Qabool F Name L Name Sadam Arif Kamal Noor Asif Wajid Salman Khan Shabeer Ali Student Professor F Name L Name Ahmad Ashraf Niaz Shah Ali Qabool Student - Professor F Name L Name Kamal Noor Salman Khan Shabeer Ali Professor - Student Tuesday, November 10, 2015 19CSE&S
  • 20. Tuesday, November 10, 2015 20CSE&S