Relational Algebra MBAD 613 R. Nakatsu
Relational Data Manipulation Language Query-by-Example; Query-by-Form Transform-Oriented Languages Relational Algebra Relational Calculus
DML Interfaces Forms Query Language Interface SELECT Name, Age FROM PATIENT WHERE Physician = ‘Levy’ © 2000 Prentice Hall
Domain Definitions © 2000 Prentice Hall
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 © 2000 Prentice Hall
Relational Operators 1.Union (A U B or A + B) 2.Difference (A – B) 3.Intersection (A ∩ B) 4.Projection 5.Selection 6.Product (A X B) 7.Join (equijoiin, outer join) 8.Division (A / B)
1. Union Adding 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. © 2000 Prentice Hall
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. © 2000 Prentice Hall
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. © 2000 Prentice Hall
4. Projection Selects specified attributes (columns) from a relation” © 2000 Prentice Hall
5. Selection Selects tuples (rows) from a relation. © 2000 Prentice Hall
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 © 2000 Prentice Hall
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 a a1 a2 a3 b b1 b2 b1 b2 b3 b b1 b2ABB What is AB / B?
Example DataStudentEnroll Course