Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Following questions have been asked in GATE CS exam.

1. Given the relations


employee (name, salary, deptno) and
department (deptno, deptname, address)
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
Answer: (c)
. Given the following relation instance.
x y z
1 4 2
1 5 3
1 6 3
3 2 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
Answer: (b)
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 Armstrong’s 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
From these rules, we can derive these secondary rules:

* 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 don’t 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.

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
Answer: (a)
Explanation:
The query selects all attributes of r. Since we have distinct in query, result can be equal to r only if r
doesn’t 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.
49
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?
(A) x = 5 AND not(not(x = 5))
(B) x = 5 AND x> 4 and x < 6, where x is an integer
(C) x < 5 AND not (x = 5)
(D) None of the above

Answer: (C)

Explanation: For all values smaller than 5, x < 5 will always be true but x = 5 will be false.
https://www.youtube.com/watch?v=l4AghUYGXxo

You might also like