Database Management Systems - Prof. Holowczak

Zicklin School of Business - Baruch College
City University of New York

Database Management Systems


Relational Algebra

What You'll Learn This Week

Relational Algebra

Elmasri/Navathe (3rd) ed. Kroenke (7th ed.) Connolly/Begg (3rd Ed.) Rob/Coronel (5th ed) Hoffer, Prescott & McFadden (6th ed.) Mata-Toledo / Cushman
Chapter 7 Chapter 8 Chapter 4 N/A N/A Shaum's Outlines Ch. 2

Set Theoretic Operations

Consider the following relations R and S
R
First Last Age
Bill Smith 22
Sally Green 28
Mary Keen 23
Tony Jones 32
S
First Last Age
Forrest Gump 36
Sally Green 28
DonJuan DeMarco 27

R S
First Last Age
Bill Smith 22
Sally Green 28
Mary Keen 23
Tony Jones 32
Forrest Gump 36
DonJuan DeMarco 27

R - S
First Last Age
Bill Smith 22
Mary Keen 23
Tony Jones 32

R S
First Last Age
Sally Green 28

Union Compatible Relations

Exercises

Cartesian Product

Selection Operator

Selection Examples

Assume the following relation EMP has the following tuples:

Name Office Dept Rank
Smith 400 CS Assistant
Jones 220 Econ Adjunct
Green 160 Econ Assistant
Brown 420 CS Associate
Smith 500 Fin Associate

Exercises

Projection Operator

Projection Examples

Assume the same EMP relation above is used.

Combining Selection and Projection

Exercises


Aggregate Functions

Aggregate Function Examples

Assume the relation EMP has the following tuples:

Name Office Dept Salary
Smith 400 CS 45000
Jones 220 Econ 35000
Green 160 Econ 50000
Brown 420 CS 65000
Smith 500 Fin 60000

Join Operation

Join Examples

Assume we have the EMP relation from above and the following DEPART relation:
Dept MainOffice Phone
CS 404 555-1212
Econ 200 555-1234
Fin 501 555-4321
Hist 100 555-9876

Natural Join

Outer Join

Assume we have two relations: PEOPLE and MENU:
PEOPLE:
Name Age Food
Alice 21 Hamburger
Bill 24 Pizza
Carl 23 Beer
Dina 19 Shrimp
MENU:
Food Day
Pizza Monday
Hamburger Tuesday
Chicken Wednesday
Pasta Thursday
Tacos Friday

Outer Union

How to make Relational Algebra Symbols in MS Word

When doing homework assignments and projects, it is very helpful to be able to type these relational algebra symbols into MS Word or other work processor. Since we mainly use MS Word or another word processor running in Microsoft Windows, we demonstrate them here.

Most of the relational algebra symbols can be produced using the "Symbol" font. One way to do this is to use the Symbol choice on the Insert menu in MS Word. This is shown below:

The following dialog box will appear:

By default, the symbols displayed on this screen will use the Symbol font.

Some symbols such as join and outer join are not available in this fashion. For these you can copy and paste the graphics in the MS Word file linked here. All of the relational algebra symbols are included.


File: ra_index.html Date: Mon Feb 18 09:54:01 EST 2002
All materials Copyright, 1997-2002 Richard Holowczak