Presentation is loading. Please wait.

Presentation is loading. Please wait.

Theory behind the relational engine

Similar presentations


Presentation on theme: "Theory behind the relational engine"— Presentation transcript:

1 Theory behind the relational engine
Relational Algebra Theory behind the relational engine

2 Relational Set Operators
Relational algebra Defines theoretical way of manipulating table contents using relational operators Use of relational algebra operators on existing relations produces new relations: SELECT DIFFERENCE PROJECT JOIN UNION PRODUCT INTERSECT DIVIDE

3 Union Combines all rows from two tables, excluding duplicate rows. The tables must have the same attribute characteristics.

4 Intersect Yields only the rows that appear in both tables. The tables must have the same attribute characteristics. Difference Yields all rows in one table that are not found in the other table. Subtracts one table from the other. The tables must have the same attribute characteristics.

5 DIVIDE This uses one single-column table as the divisor and one 2-column table as the dividend. The tables must have a common column. The output of the operation is a single column with the values of column ‘a’ from the dividend tables rows where the value of the common column in both tables match.

6 Product Yields all possible pairs of rows from two tables – also known as Cartesian product. If one table has six rows and the other tables has three rows the resulting table will have 18 rows. 6 X 3 = 18

7 Project Yields all values for selected attributes. Yields a VERTICAL SUBSET of a table.

8 Select Also known as Restrict, yields values for all rows found in the table that satisfy a given condition. SELECT can be used to list all the row values or it can yield only those rows that match a specified criterion. Yields a HORIZONTAL SUBSET of a table.

9 Join Allows information to be combined from two or more tables. This is the real power behind the relational database, where independent tables can be linked by common attributes (PK to FK fields).

10 Relational Algebra Operators (continued)
Combines every record with every record from each table First, a Product is completed.

11 Relational Algebra Operators (continued)
Gets rid of every row where the PK/FK does not match Next, a SELECT occurs using the PK and FK as selection criteria.

12 Relational Algebra Operators (continued)
Gets rid of the duplicated key Finally, we get rid of the extra column. Remember, project yields the vertical subset, which gets rid of one of the duplicate PK-FK fields.

13 Relational Algebra Operators (continued)

14 Relational Algebra Operators (continued)
Outer Joins are useful for finding values that cause referential integrity problems.


Download ppt "Theory behind the relational engine"

Similar presentations


Ads by Google