CH8 - The Relational Algebra and Relational Calculus Flashcards
8.9. How does tuple relational calculus differ from domain relational calculus?
(1) the tuple relational calculus, which uses tuple variables that range over tuples (rows) of relations, and (2) the domain relational calculus, which uses domain variables that range over domains (columns of rela- tions).
8.1. List the operations of relational algebra
- Set operations
UNION, INTERSECTION, SET DIFFERENCE (MINUS), and CARTESIAN PRODUCT (als
UNION ALL, INTERSECT ALL, and EXCEPT ALL) that do not eliminate duplicates (see Section 6.3.4).
- unary operations SELECT and PROJECT operations RENAME operation - binary operations we discuss JOIN and other complex , NATURAL JOIN THETA JOIN EQUIJOIN - de aggregate functions, w - OUTER JOINs and OUTER UNIONs - Division
8.1 Select purpose
- o choose a subset of the tuples from a relation that satisfies a selection condition.3
8.1 Project purpose
The PROJECT operation, on the other hand, selects certain columns from the table and discards the other columns. I
8.1 Rename purpose
al RENAME operation—which can rename either the rela- tion name or the attribute names, or both—as a unary operator.
8.2. What is union compatibility? Why do the UNION, INTERSECTION, and DIFFERENCE operations require that the relations on which they are applied be union compatible?
- ed must have the same type of tuples
- Two relations R(A1, A2, … , An) and S(B1, B2, … , Bn) are said to be union compatible (or type compatible) if they have the same degree n and if dom(Ai) = dom(Bi) for 1 ≤ i ≤ n.
- It is necessary because they would not create a valid relation
8.1 Union purpose
The result of this operation, denoted by R ∪ S, is a relation that includes all tuples that are either in R or in S or in both R and S. Duplicate tuples are eliminated.
8.1 INTERSECTION purpose
The result of this operation, denoted by R ∩ S, is a relation that includes all tuples that are in both R and S.
8.1 MINUS purpose
: The result of this operation, denoted by R – S, is a relation that includes all tuples that are in R but not in S
8.1 CARTESIAN PRODUCT purpose
do not have to be union compatible. In its binary form, this set operation produces a new element by combining every member (tuple) from one relation (set) with every member (tuple) from the other relation (set). In
8.1 JOIN purpose
combine related tuples from two rela- tions into single “longer” tuples.
- example: To get the manager’s name, we need to com- bine each department tuple with the employee tuple whose Ssn value matches the Mgr_ssn value in the department tuple.
8.4. Discuss the various types of inner join operations. Why is theta join required?
- . Such a JOIN, where the only comparison operator used is =, is called an EQUIJOIN.
- Because one of each pair of attributes with identical values is superfluous, a new operation called NATURAL JOIN—denoted by *—was created to get rid of the second (superfluous) attribute in an EQUIJOIN condition.6
- A general join condition is of the form
AND AND … AND
where each is of the form Ai θ Bj, Ai is an attribute of R, Bj is an attri- bute of S, Ai and Bj have the same domain, and θ (theta) is one of the comparison operators {=, , ≥, ≠} - Theta join is required to only show the results that meet the condition and removes the ones that not.
8.3. Discuss some types of queries for which renaming of attributes is necessary in order to specify the query unambiguously.
- NATURAL JOIN requires that the two join attributes (or each pair of join attributes) have the same name in both relations
- s. If this is not the case, a renaming operation is applied first.
8.5. What role does the concept of foreign key play when specifying the most common types of meaningful join operations?
- in EQUIJOIN and NATURAL JOIN they join on attributes with the same value. Foreign keys reference a primary key in another relation, therefore it a tupple has a foreign key then both tupples have the same value. This makes a good attribute for these joins
8.1 Division purpose
- Retrieve the names of employees who work on all the projects that ‘John Smith’ works on.
- . This means that, for a tuple t to appear in the result T of the DIVISION, the values in t must appear in R in combination with every tuple in S.