relational algebra mbad 613 r. nakatsu. relational data manipulation language query-by-example;...

of 18 /18
Relational Algebra MBAD 613 R. Nakatsu

Post on 13-Dec-2015

216 views

Category:

Documents

Embed Size (px)

TRANSCRIPT

Relational Algebra

Relational Data Manipulation Language

• Query-by-Example; Query-by-Form• Transform-Oriented Languages• Relational Algebra• Relational Calculus

DML Interfaces

• Forms

• Query Language InterfaceSELECT Name, AgeFROM PATIENTWHERE Physician = ‘Levy’

Domain Definitions

Domain Compatibility

Page 204

Two domains are domain compatible if

1) they have the same number of attributes and

2) each corresponding attribute has the same domain.

Attribute Domains

Relational Operators

1. Union (A U B or A + B)2. Difference (A – B)3. Intersection (A ∩ B)4. Projection5. Selection6. Product (A X B)7. Join (equijoiin, outer join)8. Division (A / B)

1. UnionAdding tuples from one relation A to those of

a second B. Denoted A + B or A U B. A and B must be domain compatible.

2. Difference

Includes tuples that occur in the first relation A but not the second B. Denoted A - B. A and B must be domain compatible.

3. Intersection

Includes tuples that are in both the first relation A and the second relation B. Denoted A ∩ B. A and B must be domain compatible.

4. Projection

Selects specified attributes (columns) from a relation”

5. Selection

Selects tuples (rows) from a relation.

6. Product

The product of two relations (sometimes called the Cartesian Product) is the concatenation of every tuple of one relation A with every tuple of a second relation B.

Denoted A X B

7. Join

The join operator allows us to combine information from two or more tables.

It is a combination of the product, selection, and (possibly) projection operations.

Two basic types: - equijoin: includes only matched pairs– outer join: the unmatched pairs

are retained, and the values are left null.

Equijoin, Natural, Left Outer

8. Division

Find those values in the first relation A that are related to all of the values in the second relation B.

Denoted A / B

Example: Division

aa1a1a2a3a3a3

bb1b2b2b1b2b3

bb1b2

ABAB BB

What is AB / B?

Example Data

StudentStudent EnrollEnroll

CourseCourse