CH8 - The Relational Algebra and Relational Calculus Flashcards

1
Q

8.9. How does tuple relational calculus differ from domain relational calculus?

A

(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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

8.1. List the operations of relational algebra

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

8.1 Select purpose

A
  • o choose a subset of the tuples from a relation that satisfies a selection condition.3
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

8.1 Project purpose

A

The PROJECT operation, on the other hand, selects certain columns from the table and discards the other columns. I

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

8.1 Rename purpose

A

al RENAME operation—which can rename either the rela- tion name or the attribute names, or both—as a unary operator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

8.1 Union purpose

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

8.1 INTERSECTION purpose

A

The result of this operation, denoted by R ∩ S, is a relation that includes all tuples that are in both R and S.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

8.1 MINUS purpose

A

: The result of this operation, denoted by R – S, is a relation that includes all tuples that are in R but not in S

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

8.1 CARTESIAN PRODUCT purpose

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

8.1 JOIN purpose

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

8.4. Discuss the various types of inner join operations. Why is theta join required? 


A
  • . 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

8.3. Discuss some types of queries for which renaming of attributes is necessary in order to specify the query unambiguously. 


A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

8.5. What role does the concept of foreign key play when specifying the most common types of meaningful join operations?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

8.1 Division purpose

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

8.7. How are the OUTER JOIN operations different from the INNER JOIN opera-
tions? How is the OUTER UNION operation different from UNION?

A
  • In inner join tuples with no match are elim- inated. While, outer joins, were developed for the case where the user wants to keep all the tuples in R, or all those in S, or all those in both relations in the result of the JOIN, regardless of whether or not they have matching tuples in the other relation
  • The OUTER UNION operation was developed to take the union of tuples from two relations that have some common attributes, but are not union (type) compatible. T
17
Q

Difference OUTER UNION and Full Outer Join

A

=

18
Q

8.8. In what sense does relational calculus differ from relational algebra, and in
what sense are they similar?

A

Diff
- In relational calculus, we write one declarative expression to specify a retrieval request; hence, there is no description of how, or in what order, to evaluate a query, it is non-procedural. In contrast, relational algebra is procedural.
Similarities
- It has been shown that any retrieval that can be specified in the basic relational alge- bra can also be specified in relational calculus, and vice versa; in other words, the expressive power of the languages is identical.

19
Q

8.11. Define the following terms with respect to the tuple calculus: tuple variable

A
  • A variable is a symbol for a tuple value that we don’t know.
  • Each tuple variable usually ranges over a particular database relation, meaning that the variable may take as its value any individual tuple from that relation.
20
Q

8.11. Define the following terms with respect to the tuple calculus: range relation

A
  • A relation from which the tuple variable can take one of its values.
  • Ex: {t | EMPLOYEE(t) AND t.Salary>50000}. EMPLOYEE(t) is the range relation
21
Q

8.11. Define the following terms with respect to the tuple calculus: expression

A
  • For each tuple variable t, the range relation R of t.
  • A condition to select particular combinations of tuples.
  • A set of attributes to be retrieved, the requested attributes.
22
Q

8.11. Define the following terms with respect to the tuple calculus: atom

A

One of the conditions’ components

23
Q

8.11. Define the following terms with respect to the tuple calculus: formula

A
  • The condition in the expression

- A formula (Boolean condition) is made up of one or more atoms connected via the logical operators AND, OR, and NOT

24
Q

8.10. Discuss the meanings of the existential quantifier (∃) and the universal quantifier (∀).

A

The (∃) quantifier is called an existential quantifier because a formula (∃t)(F) is TRUE if there exists some tuple that makes F TRUE. For the universal quantifier, (∀t)(F) is TRUE if every possible tuple that can be assigned to free occurrences of t in F is substituted for t, and F is TRUE for every such substitution.

25
Q

8.13. What is meant by a safe expression in relational calculus?

A
  • A safe expression in relational calculus is one that is guaranteed to yield a finite number of tuples as its result;
  • unsafe. For example, the expression
    {t | NOT (EMPLOYEE(t))}
26
Q

8.12. Define the following terms with respect to the domain calculus: range relation

A

range over single values from domains of attributes

27
Q

8.12. Define the following terms with respect to the domain calculus:expression.

A

{x1, x2, …, xn | COND(x1, x2, …, xn, xn+1, xn+2, …, xn+m)}

28
Q

8.14. When is a query language called relationally complete?

A

e. A relational query language L is considered relationally complete if we can express in L any query that can be expressed in relational calculus. R