0% found this document useful (0 votes)
30 views15 pages

Relational Algebra 1 Annotated

This document discusses relational algebra and its basic operators for querying relational databases. It introduces select, project, join, and cross-product operators and provides examples using a sample college admissions database with tables for colleges, students, and applications. Select picks rows, project picks columns, and join combines relations. Cross-product does a Cartesian product and join matches rows based on equality of common attributes.

Uploaded by

nomankhanawan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views15 pages

Relational Algebra 1 Annotated

This document discusses relational algebra and its basic operators for querying relational databases. It introduces select, project, join, and cross-product operators and provides examples using a sample college admissions database with tables for colleges, students, and applications. Select picks rows, project picks columns, and join combines relations. Cross-product does a Cartesian product and join matches rows based on equality of common attributes.

Uploaded by

nomankhanawan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

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)

College
cName state enr sID

Student
sName GPA HS sID

Apply
cName major dec

Jennifer Widom

Relational Algebra (1) Simplest query: relation name Use operators to filter, slice, combine

College
cName state enr sID

Student
sName GPA HS sID

Apply
cName major dec

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

Relational Algebra (1)

College
cName state enr sID

Student
sName GPA HS sID

Apply
cName major dec

Jennifer Widom

Project operator: picks certain columns


ID and decision of all applications

Relational Algebra (1)

College
cName state enr sID

Student
sName GPA HS sID

Apply
cName major dec

Jennifer Widom

To pick both rows and columns


ID and name of students with GPA>3.7

Relational Algebra (1)

College
cName state enr sID

Student
sName GPA HS sID

Apply
cName major dec

Jennifer Widom

Duplicates
List of application majors and decisions

Relational Algebra (1)

College
cName state enr sID

Student
sName GPA HS sID

Apply
cName major dec

Jennifer Widom

Cross-product: combine two relations (a.k.a. Cartesian product)

Relational Algebra (1)

College
cName state enr sID

Student
sName GPA HS sID

Apply
cName major dec

Jennifer Widom

Cross-product: combine two relations (a.k.a. Cartesian product)

Relational Algebra (1)

Names and GPAs of students with HS>1000 who applied to CS and were rejected

College
cName state enr sID

Student
sName GPA HS sID

Apply
cName major dec

Jennifer Widom

Natural Join

Relational Algebra (1)

Enforce equality on all attributes with same name Eliminate one copy of duplicate attributes

College
cName state enr sID

Student
sName GPA HS sID

Apply
cName major dec

Jennifer Widom

Natural Join

Relational Algebra (1)

Names and GPAs of students with HS>1000 who applied to CS at college with enr>20,000 and were rejected and were rejected

College
cName state enr sID

Student
sName GPA HS sID

Apply
cName major dec

Jennifer Widom

Natural Join

Relational Algebra (1)

College
cName state enr sID

Student
sName GPA HS sID

Apply
cName major dec

Jennifer Widom

Theta Join

Relational Algebra (1)

Basic operation implemented in DBMS Term join often means theta join

College
cName state enr sID

Student
sName GPA HS sID

Apply
cName major dec

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

Jennifer Widom

You might also like