SlideShare a Scribd company logo
Jennifer Widom
Relational Databases
Relational Algebra (1)
Select, project, join
Jennifer Widom
Relational Algebra (1)
Query (expression) on set of relations produces
relation as a result
Jennifer Widom
Relational Algebra (1)
Examples: simple college admissions database
College(cName,state,enrollment)
Student(sID,sName,GPA,sizeHS)
Apply(sID,cName,major,decision)
cName state enr sID sName GPA HS sID cName major dec
College Student Apply
Jennifer Widom
Simplest query: relation name
cName state enr sID sName GPA HS sID cName major dec
College Student Apply
Relational Algebra (1)
Use operators to filter, slice, combine
Jennifer Widom
Select operator: picks certain rows
Students with GPA>3.7
Students with GPA>3.7 and HS<1000
Applications to Stanford CS major
cName state enr sID sName GPA HS sID cName major dec
College Student Apply
Relational Algebra (1)
Jennifer Widom
Project operator: picks certain columns
ID and decision of all applications
cName state enr sID sName GPA HS sID cName major dec
College Student Apply
Relational Algebra (1)
Jennifer Widom
To pick both rows and columns…
ID and name of students with GPA>3.7
cName state enr sID sName GPA HS sID cName major dec
College Student Apply
Relational Algebra (1)
Jennifer Widom
Duplicates
List of application majors and decisions
cName state enr sID sName GPA HS sID cName major dec
College Student Apply
Relational Algebra (1)
Jennifer Widom
Cross-product: combine two relations
(a.k.a. Cartesian product)
cName state enr sID sName GPA HS sID cName major dec
College Student Apply
Relational Algebra (1)
Jennifer Widom
Cross-product: combine two relations
(a.k.a. Cartesian product)
Names and GPAs of students with HS>1000 who applied to CS
and were rejected
cName state enr sID sName GPA HS sID cName major dec
College Student Apply
Relational Algebra (1)
Jennifer Widom
Natural Join
 Enforce equality on all attributes with same name
 Eliminate one copy of duplicate attributes
cName state enr sID sName GPA HS sID cName major dec
College Student Apply
Relational Algebra (1)
Jennifer Widom
Natural Join
Names and GPAs of students with HS>1000 who applied to CS
and were rejected
cName state enr sID sName GPA HS sID cName major dec
College Student Apply
Relational Algebra (1)
Names and GPAs of students with HS>1000 who applied to CS
at college with enr>20,000 and were rejected
Jennifer Widom
Natural Join
cName state enr sID sName GPA HS sID cName major dec
College Student Apply
Relational Algebra (1)
Jennifer Widom
Theta Join
 Basic operation implemented in DBMS
 Term “join” often means theta join
cName state enr sID sName GPA HS sID cName major dec
College Student Apply
Relational Algebra (1)
Jennifer Widom
Relational Algebra (1)
Query (expression) on set of relations produces
relation as a result
 Simplest query: relation name
 Use operators to filter, slice, combine
 Operators so far: select, project, cross-product,
natural join, theta join

More Related Content

PPTX
Commands
PPT
Sql Authorization
PPT
MYSQL Aggregate Functions
PPTX
Nitish 007
PPT
DBMS : Relational Algebra
PPTX
Dbms and rdbms
PDF
From crash to testcase
PPS
Database system-DBMS
Commands
Sql Authorization
MYSQL Aggregate Functions
Nitish 007
DBMS : Relational Algebra
Dbms and rdbms
From crash to testcase
Database system-DBMS

Viewers also liked (20)

PPTX
Data integrity Dbms presentation 12 cs 18
PPTX
Characteristic of dabase approach
PDF
Nested Queries Lecture
PPTX
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
PDF
3 data modeling using the entity-relationship (er) model
PPTX
Data model and entity relationship
PPT
Data manipulation instructions
PPTX
Database , 8 Query Optimization
PPT
Dbms ii mca-ch5-ch6-relational algebra-2013
PPTX
SQL Data Manipulation
PDF
Enhanced Entity-Relationship (EER) Modeling
PPTX
T-SQL Overview
PPTX
trigger dbms
PPT
SQL Views
PPTX
PPT
Er & eer to relational mapping
ODP
ER Model in DBMS
PPTX
Advanced DBMS presentation
PPTX
Acid properties
PDF
Overview of security in DBMS
Data integrity Dbms presentation 12 cs 18
Characteristic of dabase approach
Nested Queries Lecture
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
3 data modeling using the entity-relationship (er) model
Data model and entity relationship
Data manipulation instructions
Database , 8 Query Optimization
Dbms ii mca-ch5-ch6-relational algebra-2013
SQL Data Manipulation
Enhanced Entity-Relationship (EER) Modeling
T-SQL Overview
trigger dbms
SQL Views
Er & eer to relational mapping
ER Model in DBMS
Advanced DBMS presentation
Acid properties
Overview of security in DBMS
Ad

More from Tianlu Wang (20)

PDF
L7 er2
PDF
L8 design1
PDF
L9 design2
PDF
14 pro resolution
PDF
13 propositional calculus
PDF
12 adversal search
PDF
11 alternative search
PDF
10 2 sum
PDF
22 planning
PDF
21 situation calculus
PDF
20 bayes learning
PDF
19 uncertain evidence
PDF
18 common knowledge
PDF
17 2 expert systems
PDF
17 1 knowledge-based system
PDF
16 2 predicate resolution
PDF
16 1 predicate resolution
PDF
15 predicate
PDF
09 heuristic search
PDF
08 uninformed search
L7 er2
L8 design1
L9 design2
14 pro resolution
13 propositional calculus
12 adversal search
11 alternative search
10 2 sum
22 planning
21 situation calculus
20 bayes learning
19 uncertain evidence
18 common knowledge
17 2 expert systems
17 1 knowledge-based system
16 2 predicate resolution
16 1 predicate resolution
15 predicate
09 heuristic search
08 uninformed search
Ad

Recently uploaded (20)

PDF
Chapter 3 about The site of the first mass
PPTX
Copy of Executive Design Pitch Deck by Slidesgo.pptx.pptx
PPTX
Military history & Evolution of Armed Forces of the Philippines
PPTX
current by laws xxxxxxxxxxxxxxxxxxxxxxxxxxx
PPTX
400kV_Switchyard_Training_with_Diagrams.pptx
PPTX
Review1_Bollywood_Project analysis of bolywood trends from 1950s to 2025
PPTX
White Green Simple and Professional Business Pitch Deck Presentation.pptx
PPTX
G10 HOMEROOM PARENT-TEACHER ASSOCIATION MEETING SATURDAY.pptx
PDF
The-Art-of-Storytelling-in-Cinema (1).pdf
PPTX
Socio ch 1 characteristics characteristics
PPTX
4277547e-f8e2-414e-8962-bf501ea91259.pptx
PPTX
Callie Slide Show Slide Show Slide Show S
PPTX
unit5-servicesrelatedtogeneticsinnursing-241221084421-d77c4adb.pptx
PPTX
Art Appreciation-Lesson-1-1.pptx College
PPTX
CMU-PPT-LACHICA-DEFENSE FOR RESEARCH PRESENTATION
PPTX
CPAR7 ARTS GRADE 112 LITERARY ARTS OR LI
PDF
Ricardo Salinas Pliego Accused of Acting as A Narcotics Kingpin
PDF
Love & Romance in Every Sparkle_ Discover the Magic of Diamond Painting.pdf
PPTX
Theatre Studies - Powerpoint Entertainmn
PPTX
573393963-choose-your-own-adventure(2).pptx
Chapter 3 about The site of the first mass
Copy of Executive Design Pitch Deck by Slidesgo.pptx.pptx
Military history & Evolution of Armed Forces of the Philippines
current by laws xxxxxxxxxxxxxxxxxxxxxxxxxxx
400kV_Switchyard_Training_with_Diagrams.pptx
Review1_Bollywood_Project analysis of bolywood trends from 1950s to 2025
White Green Simple and Professional Business Pitch Deck Presentation.pptx
G10 HOMEROOM PARENT-TEACHER ASSOCIATION MEETING SATURDAY.pptx
The-Art-of-Storytelling-in-Cinema (1).pdf
Socio ch 1 characteristics characteristics
4277547e-f8e2-414e-8962-bf501ea91259.pptx
Callie Slide Show Slide Show Slide Show S
unit5-servicesrelatedtogeneticsinnursing-241221084421-d77c4adb.pptx
Art Appreciation-Lesson-1-1.pptx College
CMU-PPT-LACHICA-DEFENSE FOR RESEARCH PRESENTATION
CPAR7 ARTS GRADE 112 LITERARY ARTS OR LI
Ricardo Salinas Pliego Accused of Acting as A Narcotics Kingpin
Love & Romance in Every Sparkle_ Discover the Magic of Diamond Painting.pdf
Theatre Studies - Powerpoint Entertainmn
573393963-choose-your-own-adventure(2).pptx

Relational algebra1

  • 1. Jennifer Widom Relational Databases Relational Algebra (1) Select, project, join
  • 2. Jennifer Widom Relational Algebra (1) Query (expression) on set of relations produces relation as a result
  • 3. Jennifer Widom Relational Algebra (1) Examples: simple college admissions database College(cName,state,enrollment) Student(sID,sName,GPA,sizeHS) Apply(sID,cName,major,decision) cName state enr sID sName GPA HS sID cName major dec College Student Apply
  • 4. Jennifer Widom Simplest query: relation name cName state enr sID sName GPA HS sID cName major dec College Student Apply Relational Algebra (1) Use operators to filter, slice, combine
  • 5. Jennifer Widom Select operator: picks certain rows Students with GPA>3.7 Students with GPA>3.7 and HS<1000 Applications to Stanford CS major cName state enr sID sName GPA HS sID cName major dec College Student Apply Relational Algebra (1)
  • 6. Jennifer Widom Project operator: picks certain columns ID and decision of all applications cName state enr sID sName GPA HS sID cName major dec College Student Apply Relational Algebra (1)
  • 7. Jennifer Widom To pick both rows and columns… ID and name of students with GPA>3.7 cName state enr sID sName GPA HS sID cName major dec College Student Apply Relational Algebra (1)
  • 8. Jennifer Widom Duplicates List of application majors and decisions cName state enr sID sName GPA HS sID cName major dec College Student Apply Relational Algebra (1)
  • 9. Jennifer Widom Cross-product: combine two relations (a.k.a. Cartesian product) cName state enr sID sName GPA HS sID cName major dec College Student Apply Relational Algebra (1)
  • 10. Jennifer Widom Cross-product: combine two relations (a.k.a. Cartesian product) Names and GPAs of students with HS>1000 who applied to CS and were rejected cName state enr sID sName GPA HS sID cName major dec College Student Apply Relational Algebra (1)
  • 11. Jennifer Widom Natural Join  Enforce equality on all attributes with same name  Eliminate one copy of duplicate attributes cName state enr sID sName GPA HS sID cName major dec College Student Apply Relational Algebra (1)
  • 12. Jennifer Widom Natural Join Names and GPAs of students with HS>1000 who applied to CS and were rejected cName state enr sID sName GPA HS sID cName major dec College Student Apply Relational Algebra (1) Names and GPAs of students with HS>1000 who applied to CS at college with enr>20,000 and were rejected
  • 13. Jennifer Widom Natural Join cName state enr sID sName GPA HS sID cName major dec College Student Apply Relational Algebra (1)
  • 14. Jennifer Widom Theta Join  Basic operation implemented in DBMS  Term “join” often means theta join cName state enr sID sName GPA HS sID cName major dec College Student Apply Relational Algebra (1)
  • 15. Jennifer Widom Relational Algebra (1) Query (expression) on set of relations produces relation as a result  Simplest query: relation name  Use operators to filter, slice, combine  Operators so far: select, project, cross-product, natural join, theta join