Sie sind auf Seite 1von 4

# 1. .

## Given the relations

employee (name, salary, deptno) and
Which of the following queries cannot be expressed using the basic relational algebra
operations (U, -, x, , , p)? (GATE CS 2000)
(a) Department address of every employee
(b) Employees whose name is the same as their department name
(c) The sum of all employees salaries
(d) All employees of a given department
Explanation:
The six basic operators of relational algebra are the selection( ), the projection(), the Cartesian product
(x) (also called the cross product or cross join), the set union (U), the set difference (-), and the rename
(p). These six operators are fundamental in the sense that none of them can be omitted without losing
expressive power. Many other operators have been defined in terms of these six. Among the most
important are set intersection, division, and the natural join, but aggregation is not possible with these
basic relational algebra operations. So, we cannot run sum of all employees salaries with the six
operations.

## 2. Given the following relation instance.

x
1
1
1
3

y
4
5
6
2

z
2
3
3
2

Which of the following functional dependencies are satisfied by the instance? (GATE CS 2000)
(a) XY -> Z and Z -> Y
(b) YZ -> X and Y -> Z
(c) YZ -> X and X -> Z
(d) XZ -> Y and Y -> X
Explanation:
A functional dependency (FD) is a constraint between two sets of attributes in a relation from a database.

A FD X->Y require that the value of X uniquely determines the value of Y where X and Y are set of
attributes. FD is a generalization of the notion of a key.
Given that X, Y, and Z are sets of attributes in a relation R, one can derive several properties of functional
dependencies. Among the most important are Armstrongs axioms, which are used in database
normalization:

## * Subset Property (Axiom of Reflexivity): If Y is a subset of X, then X ? Y

* Augmentation (Axiom of Augmentation): If X -> Y, then XZ -> YZ
* Transitivity (Axiom of Transitivity): If X -> Y and Y -> Z, then X -> Z

## * Union: If X -> Y and X -> Z, then X -> YZ

* Decomposition: If X -> YZ, then X -> Y and X -> Z
* Pseudotransitivity: If X -> Y and YZ -> W, then XZ -> W

In the above question, Y uniquely determines X and Z, for a given value of Y you can easily find out
values of X and Z.
So, Y -> X and Y -> Z hold for above schema.
From rule of augmentation we can say YZ->X. If we understand the notion of FD, we dont need to apply
axioms to find out which option is true, just by looking at the schema and options we can say that (b) is
true.
3. Given relations r(w, x) and s(y, z), the result of
select distinct w, x
from r, s
is guaranteed to be same as r, provided (GATE CS 2000)
(a) r has no duplicates and s is non-empty
(b) r and s have no duplicates
(c) s has no duplicates and r is non-empty
(d) r and s have the same number of tuples

Explanation:
The query selects all attributes of r. Since we have distinct in query, result can be equal to r only if r
doesnt have duplicates.
If we do not give any attribute on which we want to join two tables, then the queries like above become
equivalent to Cartesian product. Cartisian product of two sets will be empty if any of the two sets is empty.
So, s should have atleast one record to get all rows of r.

4. In SQL, relations can contain null values, and comparisons with null values are treated as
unknown. Suppose all comparisons with a null value are treated as false. Which of the
following pairs is not equivalent? (GATE CS 2000)
(a) x = 5, not (not (x = 5)
(b) x = 5, x > 4 and x < 6, where x is an integer
(c) x < 5, not(x = 5)
(d) None of the above
Explanation:
It doesnt need much explanation. For all values smaller than 5, x < 5 will always be true but x = 5 will be
false.
5. Consider a schema R(A, B, C, D) and functional dependencies A -> B and C -> D. Then the
decomposition of R into R1 (A, B) and R2(C, D) is (GATE CS 2001)
a) dependency preserving and loss less join
b) loss less join but not dependency preserving
c) dependency preserving but not loss less join
d) not dependency preserving and not loss less join
Explanation:
Dependency Preserving Decomposition:
Decomposition of R into R1 and R2 is a dependency preserving decomposition if closure of functional
dependencies after decomposition is same as closure of of FDs before decomposition.
A simple way is to just check whether we can derive all the original FDs from the FDs present after
decomposition.

In the above question R(A, B, C, D) is decomposed into R1 (A, B) and R2(C, D) and there are only two
FDs A -> B and C -> D. So, the decomposition is dependency preserving
Lossless-Join Decomposition:
Decomposition of R into R1 and R2 is a lossless-join decomposition if at least one of the following
functional dependencies are in F+ (Closure of functional dependencies)
R1 R2 R1
OR
R1 R2 R2

In the above question R(A, B, C, D) is decomposed into R1 (A, B) and R2(C, D), and R1 R2 is empty.
So, the decomposition is not lossless.