Chapter 8 Flashcards

1
Q

_________ is the basic set of operations for the relational model.

A

Relational algebra

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

T/F: Relational operations enable a user to specify basic retrieval requests (or queries.)

A

True.

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

T/F: The result of a relational operation is a new relation, which may have been formed from one or more input relations.

A

True.

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

“The result of a relational operation is a new relation, which may have been formed from one or more input
relations.”

This property makes the algebra ______.

A

“closed” (all objects in relational algebra are relations)

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

T/F: Not all objects in relational algebra are relations.

A

F, all objects in relational algebra are relations.

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

T/F: The new relations produced by the algebra operations can be further manipulated using operations of the same algebra.

A

True.

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

A sequence of relational algebra operations forms a ______________.

A

relational algebra expression

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

T/F: The result of a relational algebra expression is also a relation that represents the result of a database query (or retrieval request.)

A

True.

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

Relational Algebra consists of several groups of operations…

1.Unary Relational Operations, includes:
SELECT
PROJECT
RENAME

What are their symbols?

A

σ (sigma), π (pi), ρ (rho)

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

Relational Algebra consists of several groups of operations…

  1. Relational Algebra Operations From Set Theory

Which include?

A

UNION , INTERSECTION, DIFFERENCE (or MINUS, – ), CARTESIAN PRODUCT ( x ).

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

Relational Algebra consists of several groups of operations…

  1. Binary Relational Operations

Which include?

A

JOIN (several variations of JOIN exist), DIVISION.

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

Relational Algebra consists of several groups of operations…

  1. Additional Relational Operations

Which include?

A

OUTER JOINS, OUTER UNION, AGGREGATE FUNCTIONS.

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

In general, the select operation is denoted by:
σ <selection>(R)</selection>

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

Write the query statement using algebra operations:

Select the EMPLOYEE tuples whose department number is 4.

A

σ DNO = 4 (EMPLOYEE)

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

Write the query statement using algebra operations:

Select the employee tuples whose salary is greater than $30,000.

A

σ SALARY > 30,000 (EMPLOYEE)

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

T/F: The number of tuples in the result of a SELECT is less than (or equal to) the number of tuples in the input relation R.

A

True.

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

T/F: SELECT σ is commutative.

A

true. ex:
σ <condition1>(σ < condition2> (R)) = σ <condition2> (σ < condition1> (R))</condition2></condition1>

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

T/F: The SELECT operation σ <selection>(R) produces a relation S that has the same schema (same attributes) as R.</selection>

A

true.

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

Write the sql equivalent of the following:

σ SALARY > 30,000 (EMPLOYEE)

A

SELCT * FROM Employee WHERE Salary > 30000;

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

Name the algebra operation:

_________ operation keeps certain columns (attributes) from a relation and discards the other columns.

A

PROJECT

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

Name the algebra operation:

________ creates a vertical partitioning.

A

PROJECT.
(In other words, The list of specified columns (attributes) is kept in each tuple,
while the other attributes in each tuple are discarded.)

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

Write the query for the following using relational operations:

List each employee’s first and last name and salary.

A

π LNAME, FNAME, SALARY (EMPLOYEE)

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

The general form of the project operation is:
π<attribute>(R)</attribute>

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

The project operation removes any __________ tuples.

A

duplicate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
T/F: the result of the project operation must be a set of tuples.
True, a set of tuples that do not include duplicates as Mathematical sets do not allow duplicate elements.
26
T/F: The number of tuples in the result of projection is always less or equal to the number of tuples in R.
True.
27
T/F: If the list of attributes includes a key of R, then the number of tuples in the result of PROJECT is *EQUAL* to the number of tuples in R.
True.
28
T/F: PROJECT is commutative.
False, PROJECT is NOT commutative. π (R) ) = π (R) as long as contains the attributes in .
29
Find the results of the following: σ(Dno=4 AND Salary>25000) OR (Dno=5 AND Salary>30000)(EMPLOYEE)
30
Find the result of the following: πLname, Fname, Salary(EMPLOYEE).
31
Write the algebra operation equivalence to the following sql statement: SELECT DISTINCT Lname, Fname, Salary FROM Employee;
πLname, Fname, Salary(EMPLOYEE).
32
T/F: We can apply one operation at a time and create intermediate result relations, instead of writing a single relational algebra expression.
True.
33
Write a single relational algebra expression for the following: retrieve the first name, last name, and salary of all employees who work in department number 5.
π Fname, Lname, Salary (σ DNO = 5 (EMPLOYEE))
34
Write the intermediate result relations for the following: retrieve the first name, last name, and salary of all employees who work in department number 5.
DEP5_EMPS ← σ DNO=5(EMPLOYEE) RESULT ← π FNAME, LNAME, SALARY (DEP5_EMPS)
35
T/F: The RENAME operation is used to rename the attributes of a relation or the relation name or BOTH.
true.
36
Write the results of the following: TEMP ← σDno=5(EMPLOYEE) R(First_name, Last_name, Salary) ← πFname, Lname, Salary(TEMP)
37
In UNION operation, all _______ tuples are eliminated.
duplicate
38
T/F: The two operand relations R and S must be “type compatible” (or UNION compatible)
True, R and S must have same number of attributes and each pair of corresponding attributes must be type compatible (have same or compatible domains)
39
Write the alegbra operations for the following: retrieve the social security numbers of all employees who either work in department 5 or directly supervise an employee who works in department 5.
DEP5_EMPS ← σDNO=5 (EMPLOYEE) RESULT1 ← π SSN(DEP5_EMPS) RESULT2(SSN) ← πSUPERSSN(DEP5_EMPS) RESULT ← RESULT1 ∪ RESULT2 [The union operation produces the tuples that are in either RESULT1 or RESULT2 or both.]
40
T/F: In order to perform relational algerbra operations for any set operation, the operands must be type compatible.
True. (so you need type compatibilty to perform not just union but also intersect and minus)
41
T/F: The resulting relation for R1 ∪ R2 (also for R1 ∩ R2, or R1 – R2) has the same attribute names as the first operand relation R1 (by convention).
true.
42
________ operation is used to combine tuples from two relations in a combinatorial fashion.
CARTESIAN (or CROSS) PRODUCT
43
T/F: if R has nR tuples (denoted as |R| = nR ), and S has nS tuples, then R x S will have nR * nS tuples.
True.
44
T/F: The two operands do NOT have to be "type compatible” in a cartesian product operation.
true.
45
T/F: The resulting relation state of a cartesian product operation has one tuple for each combination of tuples—one from R and one from S.
true.
46
T/F: Generally, CARTESIAN PRODUCT is not and cannot be a meaningful operation.
false, it can be a meanigfuk operation when followed by other operations.
47
Turn the following into a meaningful cartesian product operation: FEMALE_EMPS ← σ SEX=’F’(EMPLOYEE) EMPNAMES ← π FNAME, LNAME, SSN (FEMALE_EMPS) EMP_DEPENDENTS ← EMPNAMES x DEPENDENT
ACTUAL_DEPS ← σ SSN=ESSN(EMP_DEPENDENTS) RESULT ← π FNAME, LNAME, DEPENDENT_NAME (ACTUAL_DEPS)
48
We can use a single ________ operation instead of a cartesian product followed by a select operation sequence, to combine two related tuples from two relations.
JOIN
49
The general form of a join operation on two relations R(A1, A2, . . ., An) and S(B1, B2, . . ., Bm) is:
R ⨝ S
50
find the following using relational alegbra operations: retrieve the name of the manager of each department.
DEPT_MGR ← DEPARTMENT ⨝MGRSSN=SSN EMPLOYEE
51
The general case of JOIN operation is called a ________: R ⨝theta S
theta-join
52
T/F: The join condition theta can be any general boolean expression of R and S, such as: R.Ai
true. Most join conditions involve one or more equality conditions “AND”ed together, for example: R.Ai=S.Bj AND R.Ak=S.Bl AND R.Ap=S.Bq
53
A JOIN operation, where the only comparison operator used is =, is called an ________. Ex: R.Ai=S.Bj AND R.Ak=S.Bl AND R.Ap=S.Bq
EQUIJOIN
54
T/F: In the result of an EQUIJOIN we always have one or more pairs of attributes that have identical values in every tuple.
true.
55
Another variation of JOIN called _________ — denoted by * — was created to get rid of the second (superfluous) attribute in an EQUIJOIN condition.
NATURAL JOIN
56
The standard definition of natural join requires that the two join attributes, or each pair of corresponding join attributes, have the same ______ in both relations.
name.
57
Find the result of the following relational algebra operations: project_dept ← project * dept.
explanation: a natural join happens by the only attribute with the same name, which is DNUMBER. An implicit join condition is created based on this attribute.. DEPARTMENT.DNUMBER=DEPT_LOCATIONS.DNUMBER [So in other words what happens in natural join is that an implicit condition is created on the attribute that they share the same name with on both relations.]
58
Find the result of the following relational algebra operations: dept_locs ← department * dept_locations
59
Write the implicit join condition that will be created and the result in the following natural join: Q ← R(A,B,C,D) * S(C,D,E)
implicit join condition: R.C=S.C AND R.D.=S.D Result keeps only one attribute of each such pair: Q(A,B,C,D,E)
60
The set of operations including SELECT s, PROJECT p , UNION È, DIFFERENCE - , RENAME r, and CARTESIAN PRODUCT X is called a _______ because any other relational algebra expression can be expressed by a combination of these five operations. Ex: R ∩ S = (R ∪ S ) – ((R - S) ∪ (S - R)) or R ⨝S = σ (R X S)
complete set.
61
T/F: For a tuple t to appear in the result T of the DIVISION operation, the values in t must appear in R in combination with one tuple in S.
false, with EVERY tuple in S.
62
Find the following using relational algebra operations: Retrieve the names of employees who work on **all** the projects that ‘John Smith’ works on.
1-list of project numbers that ‘John Smith’ works on in the intermediate relation SMITH_PNOS. 2-create a relation that includes a tuple in the intermediate relation SSN_PNOS. 3-Finally, apply the DIVISION operation to the two relations, which gives the desired employees’ Social Security numbers. 3-Finally, apply the DIVISION operation to the two relations, which gives the desired employees’ Social Security numbers. SMITH ← σFname=‘John’ AND Lname=‘Smith’(EMPLOYEE) SMITH_PNOS ← πPno(WORKS_ON⨝ Essn=Ssn SMITH) SSN_PNOS ← πEssn, Pno(WORKS_ON) SSNS(Ssn) ← SSN_PNOS ÷ SMITH_PNOS RESULT ← πFname, Lname(SSNS * EMPLOYEE)
63
Find the results of the following: SSN_PNOS ÷ SMITH_PNOS
64
Find the result of the following: T ← R ÷ S
65
_________ operation produces a relation R(X) that includes all tuples t[X] in R1(Z) that appear in R1 in combination with every tuple from R2(Y), where Z = X ∪ Y
DIVISION
66
__________ is an internal data structure to represent a query.
Query Tree
67
T/F: Query Tree is a standard technique for estimating the work involved in executing the query, the generation of intermediate results, and the optimization of execution.
true.
68
In a Query Tree, ________ [left side] nodes stand for operations like selection, projection, join, renaming, division, etc. ______ [right side] nodes represent base relations.
internal, leaf.
69
Draw the Query Tree for the following: For every project located in ‘Stafford’, list the project number, the controlling department number, and the department manager’s last name, address, and birth date.
70
T/F: duplicates are eliminated when an aggregate function is applied.
False, they are NOT eliminated. if you want to eliminate duplicates remember to use DISTINCT.
71
T/F: NULL values are considered in aggregation.
False, they are NOT.
72
T/F: In NATURAL JOIN and EQUIJOIN, Tuples with null in the join attributes are also eliminated.
true.
73
Write the following using relational algebra operations: For each department, retrieve the DNO, COUNT SSN, and AVERAGE SALARY.
DNO ℱ COUNT SSN, AVERAGE Salary (EMPLOYEE)
74
T/F: Grouping can be combined with Aggregate Functions.
True. It is done by adding the grouping attribute to the left of the aggregate function symbol. ex: DNO ℱ COUNT SSN, AVERAGE Salary (EMPLOYEE)
75
A set of operations, called __________ can be used when we want 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.
OUTER JOIN
76
The ________ operation keeps every tuple in the first or left relation R; if no matching tuple is found in S, then the attributes of S in the join result are filled or “padded” with null values.
LEFT OUTER JOIN. A similar operation, right outer join, keeps every tuple in the second or right relation S in the result
77
A third operation, ____________ , keeps all tuples in both the left and the right relations when no matching tuples are found, padding them with null values as needed.
FULL OUTER JOIN
78
Write the following using relational algebra operations: list of all employee names as well as the name of the departments they manage if they happen to manage a department.
TEMP ← (EMPLOYEE Ssn=Mgr_ssnDEPARTMENT) RESULT ← πFname, Minit, Lname, Dname(TEMP)
79
The_________ operation was developed to take the union of tuples from two relations if the relations are not type compatible.
OUTER UNION Example: An outer union can be applied to two relations whose schemas are STUDENT(Name, SSN, Department, Advisor) and INSTRUCTOR(Name, SSN, Department, Rank) Tuples from the two relations are matched based on having the same combination of values of the shared attributes— Name, SSN, Department. If a student is also an instructor, both Advisor and Rank will have a value; otherwise, one of these two attributes will be null. The result relation STUDENT_OR_INSTRUCTOR will have the following attributes: STUDENT_OR_INSTRUCTOR (Name, SSN, Department, Advisor, Rank)
80
T/F: The OUTER UNION operation will take the union of tuples in two relations R(X, Y) and S(X, Z) that are partially compatible, meaning that only some of their attributes, say X, are type compatible.
True. The attributes that are type compatible are represented only once in the result, and those attributes that are not type compatible from either realtion are also kept in the result relation T(X, Y, Z).
81
Find the following using relational algebra operations: Retrieve the name and address of all employees who work for the Research’ department.
82
Find the following using relational algebra operations: Retrieve the names of employees who have no dependents.
83
Write the following as a single expression:
84
Rewrite the following as a single expression: