relational algebra relational calculus. relational algebra operators relational algebra defines the...

9
Relational Algebra Relational Calculus

Post on 20-Dec-2015

220 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Relational Algebra Relational Calculus. Relational Algebra Operators Relational algebra defines the theoretical way of manipulating table contents using

Relational Algebra

Relational Calculus

Page 2: Relational Algebra Relational Calculus. Relational Algebra Operators Relational algebra defines the theoretical way of manipulating table contents using

Relational Algebra Operators

Relational algebra defines the theoretical way of manipulating table contents using the relational functions Shows HOW

Operators SELECT PROJECT JOIN INTERSECT UNION DIFFERENCE PRODUCT DIVIDE

Page 3: Relational Algebra Relational Calculus. Relational Algebra Operators Relational algebra defines the theoretical way of manipulating table contents using

Relational Algebra Operators

SELECT yields values for all attributes found in a table. It yields a horizontal subset of a table. σpredicate (R)

PROJECT produces a list of all values for selected attributes. It yields a vertical subset of a table. Πa1…an (R)

DIFFERENCE yields all rows in one table that are not found in the other table; i.e., it subtracts one table from the other. The tables must be union compatible. R - S

Page 4: Relational Algebra Relational Calculus. Relational Algebra Operators Relational algebra defines the theoretical way of manipulating table contents using

Relational Algebra Operators A PRODUCT produces a list of all possible

pairs of rows from two tables. Default is CARTESIAN PRODUCT R X S Constrain with:

A SELECT is performed to yield only the rows for which the common attribute values match.

A PROJECT is performed to yield a single copy of each attribute, thereby eliminating duplicate column.

DIVIDE requires the use of one single-column table and one two-column table. R÷S

Page 5: Relational Algebra Relational Calculus. Relational Algebra Operators Relational algebra defines the theoretical way of manipulating table contents using

Relational Algebra Operators UNION combines all rows from

two tables. The two tables must be union compatible. R υ S

INTERSECT produces a listing that contains only the rows that appear in both tables. The two tables must be union compatible. R S

υ

Page 6: Relational Algebra Relational Calculus. Relational Algebra Operators Relational algebra defines the theoretical way of manipulating table contents using

Relational Algebra Operators

JOIN allows us to combine information from two or more tables. JOIN is the real power behind the relational database, allowing the use of independent tables linked by common attributes. Theta join R F S = σF(R X S) Equijoin Function is = Natural join One occurrence of common attribute

eliminated. Outer join R S Usually left Semijoin join and projectυ

Page 7: Relational Algebra Relational Calculus. Relational Algebra Operators Relational algebra defines the theoretical way of manipulating table contents using

Relational Database Software Classification

Relational Database Classification

Page 8: Relational Algebra Relational Calculus. Relational Algebra Operators Relational algebra defines the theoretical way of manipulating table contents using

Relational Calculus Specifies WHAT is retrieved QBE Predicate calculus – truth value for

each proposition Tuple relational calculus Domain relational calculus {x|P(x)}

Page 9: Relational Algebra Relational Calculus. Relational Algebra Operators Relational algebra defines the theoretical way of manipulating table contents using

Relational Calculus Well-formed formula –wff

And, or, not Quantifiers

Existential quantifier Must be true for at least one instance

Universal quantifier V True for every instance

E