Test 2 - Databases | Computer Science(CS)

Description: GATE Previous year Topic Wise Questions and Answers | Databases
Number of Questions: 27
Created by:
Tags: Databases GATE CS
Attempted 0/27 Correct 0 Score 0

Given relations r(w,x) and s(y,z), the result of select distinct w,x from r,s is guaranteed to be the same as r, provided

  1. r has no duplicate and s is non empty

  2. r and s have no duplicate

  3. s has no duplicate and r is non empty

  4. r and s have the same number of tuples


Correct Option: 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.

Suppose the adjacency relation of vertices in a graph is represented in a table Adj (X,Y). Which of the following queries cannot be expressed by a relational algebra expression of constant length?

  1. List all vertices adjacent to a given vertex.

  2. List all vertices which have self loops.

  3. List all vertices which belong to cycles of less than three vertices.

  4. List all vertices reachable from a given vertex.


Correct Option: C
Explanation:

The database contains the adjacency list of the graph. So relation algebra will face problems while calculating the length of cycle. The query would execute in one tuple only.

Consider the following relation schema pertaining to a students database: Student (rollno, name, address) Enroll (rollno, courseno, coursename) where the primary keys are shown underlined. The number of tuples in the student and Enroll tables are 120 and 8 respectively. What are the maximum and minimum number of tuples that can be present in (Student*Enroll), where '*' denotes natural join?

  1. 8, 8

  2. 120, 8

  3. 960, 8

  4. 960, 120


Correct Option: A
Explanation:

The boundary cases are when either all the tuples of Enroll table belong to one roll number, so there can be at most 8 roll number and course number combinations or the other case is when all the tuples belong to different roll no. this also has 8 tuples. So (8,8) = (max,min)

Let r and s be two relations over the relation schemes R and S respectively, and let A be an attribute in R. Then the relational algebra expression $\sigma_A =_a (rs)$ is always equal to

  1. $\sigma_A =_a (r)$

  2. r

  3. $\sigma_A =_a (rs)$

  4. none of the above


Correct Option: C
Explanation:

Relation R is decomposed using a set of functional dependencies F and relation S is decomposed using another set of functional dependencies G. One decomposition is definitely BCNF, the other is definitely 3NF. To make a guaranteed identification, which one of the following tests should be used on the decompositions? (Assume that the closures of F and G are available).

  1. Dependency preservation

  2. Lossless join

  3. BCNF definition

  4. 3NF definition


Correct Option: C
Explanation:

BCNF is a stricter normal form than 3NF. So if we check database for BCNF, then it will definitely be in 3NF.

Let $R_1 \left(\underline{A}, B, C\right)$ and $R_2\left(\underline{D}, E \right) $ be two relation schema, where the primary keys are shown underlined, and let C be a foreign key in $R_1$ referring to $R_2$. Suppose there is no violation of the above referential integrity constraint in the corresponding relation instances $r_1$ and $r_2$. Which of the following relational algebra expressions would necessarily produce an empty relation?

  1. $\Pi_D (r_2) - \Pi_C (r_1)$

  2. $\Pi_C (r_1) - \Pi_D (r_2)$

  3. $\Pi_D \left(r_1 \bowtie_{C \neq D}r_2\right)$

  4. $\Pi_C \left(r_1 \bowtie_{C = D}r_2\right)$


Correct Option: B
Explanation:

The relation scheme student Performance (name, courselNo, rollNo, grade) has the following functional dependencies: name, courseNo $\rightarrow$grade RollNo, courseNo$\rightarrow$grade name $\rightarrow$rollNo rollNo $\rightarrow$name The highest normal form of this relation scheme is

  1. 2 NF

  2. 3NF

  3. BCNF

  4. 4 NF


Correct Option: A
Explanation:

Name, course no. $\rightarrow$ grade Roll no. course no. $\rightarrow$ grade Name, Roll no are candidate keys grade depend upon both super keys. So it is 2NF , non key attribute grade depend upon super keys fully. But not in 3NF , since grade is not fully dependent upon all candidate keys.

It is desired to design an object-oriented employee record system for a company. Each employee has a name, unique id and salary. Every employee belongs to different categories and his salary is determined by his category. The functions getName, getld and computeSalary are required. Given the class hierarchy below, possible locations for these functions are:

(i) getld is implemented in the superclass (ii) getld is implemented in the suclass (iii) getName is an abstract function in the superclass (iv) getName is implemented in the superclass (v) getName is implemented in the subclass (vi) getSalary is an abstract function in the superclass (vii) getSalary is implemented in the superclass (viii) getSalary is implemented in the subclass

Choose the best design

  1. (i),(iv),(vi).(viii)

  2. (i),(iv),(vii)

  3. (i),(iii),(v),(vi),(viii)

  4. (ii),(v),(viii)


Correct Option: A
Explanation:

Employee ID and employee name are independent of subclasses; manager engineer or secretary, so these should be implemented in super class, but salary is part of employee dependent, so abstract get salary should be in super class and its actual implementation in subclass.

The order of an internal node in a B* tree index is the maximum number of children it can have. Suppose that a child pointer takes 6 bytes, the search field value takes 14 bytes and the block size is 512 bytes. What is the order of the internal node?

  1. 24

  2. 25

  3. 26

  4. 27


Correct Option: C
Explanation:

Consider the relation Student (name, sex, marks), where the primary key is shown underlined, pertaining to students in a class that has at least one boy and one girl. What does the following relational algebra expression produce?

  1. names of girl students with the highest marks

  2. names of girl students with more marks than some boy student

  3. names of girl students with marks not less than some boy student

  4. names of girl students with more marks than all the boy students


Correct Option: D
Explanation:

This query first computes join where marks are less than or equal to marks are less than or equal to max marks, & then selects the name of all the girl students with more marks than all the boys students.

Which of the following statements about normal forms is FALSE?

  1. BCNF is stricter than 3 NF.

  2. Lossless, dependency preserving decomposition into 3 NF is always possible.

  3. Lossless, dependency preserving decomposition into BCNF is always possible.

  4. Any relation with two attributes is BCNF.


Correct Option: C
Explanation:

(1) BCNF stricter than 3NF is true. (2) True, dependency preserving lossless decomposition into 3NF is always possible by removing transitive functional dependences. (3) False, lossless dependency preserving decomposition is not possible in all the cases, when all non-  trivial functional dependencies are not dependent upon super keys. (4) Certainly relation with two attributes is in BCNF, both will consist of super key.

Consider 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?

  1. XY$\rightarrow$Z and Z$\rightarrow$ Y

  2. YZ$\rightarrow$ X and Y$\rightarrow$ Z

  3. YZ$\rightarrow$ X and X$\rightarrow$ Z

  4. XZ$\rightarrow$ Y and Y$\rightarrow$ X


Correct Option: 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 (2) is true.

Let E1 and E2 be two entities in an E-R diagram with simple single valued attributes. R1 and R2 are two relationships between E1 and E2 where R1 is one-to-many and R2 is many-to-many. R1 and R2 do not have any attributes of their own. What is the minimum number of tables required to represent this situation in relational model?

  1. 2

  2. 3

  3. 4

  4. 5


Correct Option: B
Explanation:

Which of the following relational calculus expressions is not safe?


Correct Option: C
Explanation:

In option (3)    is not safe since no criteria for selection of tuple has been given.

The following table has two attributes A and C where A is the primary key and C is the foreign key referencing A with on-delete cascade.

The set of all tuples that must be additionally deleted to preserve referential integrity when the tuple (2,4) is deleted is:

  1. (3,4) and (6,4)

  2. (5,2) and (7,2)

  3. (5,2)(7,2) and (9,5)

  4. 1


Correct Option: C
Explanation:

On delete cascade says that deletion of a primary key value should delete its all foreign key references. So in (2,4) 2 is primary key so tuples (5,2) & (7,2) should be deleted, but in (5,2) 5 is also a key so (9,5) also deleted cascade.

From the following instance of relation schema R(A,B,C), we can conclude that

A B C 1 1 1 1 1 0 2 3 2 2 3 2

  1. A functionally determines B and B functionally determines C

  2. A functionally determines B and B does not functionally determine C

  3. B does not functionally determine C

  4. A does not functionally determine B and B does not functionally determine C


Correct Option: B
Explanation:

A is said to be functionally determined by B. A has the same values as that of B for every corresponding tuple in given the database,

A B 1 1 1 1 2 3 2 3

Here if A is 1, then B is necessarily 1 and if A is 2, then B is 3. So, B is functionally determined by A. But this relationship is not true for any other pair.

With regard to the expressive power of the formal relational query languages, which of the following statements is true?

  1. Relational algebra is more powerful than relational calculus.

  2. Relational algebra has the same power as relational calculus.

  3. Relational algebra has the same power as safe relational calculus.

  4. None of the above


Correct Option: C
Explanation:

Expressive power is the capacity of formal query languages to express various query statements, so relational algebra is as powerful as relational calculus only if calculus is safe relational calculus.

Which one of the following is a key factor for preferring B+-trees to binary search trees for indexing database relation?

  1. Database relations have a large number of records.

  2. Database relations are sorted on the primary key.

  3. B+-trees require less memory than binary search trees.

  4. Data transfer from disks is in blocks.


Correct Option: D
Explanation:

B+ tree's each node size is kept almost the same to the block size of the system. This causes record data transfer from disk to memory one block at a time.

The employee information in a company is stored in the relation Employee (name, sex, salary, deptName) Consider the following SQL query select deptname from Employee where sex='M' group by deptName having avg (salary)> (select avg(salary)from Employee) It returns the names of the department in which

  1. the average salary is more than the average salary in the company

  2. the average salary of male employees is more than the average salary of all male employees in the company

  3. the average salary of male employees is more than the average salary of employees in the same department

  4. the average salary of male employees is more than the average salary in the company


Correct Option: D
Explanation:

“Select average (salary) from employee” selects average salary of the company. So the query returns the names of all the male employees of all the departments whose average salary is more than the average salary in the company.

Consider a schema R(A,B,C,D) and functional dependencies A$\rightarrow$ B and C$\rightarrow$ D. Then the decomposition of R into R1(AB) and R2] (CD)g is

  1. dependency preserving and lossless join

  2. lossless join but not dependency preserving

  3. dependency preserving but not lossless join

  4. not dependency preserving and not lossless join


Correct Option: C
Explanation:

AB+-tree index is to be built on the Name attribute of the relation STUDENT. Assume that all student names are of length 8 bytes, disk blocks are of size 512 bytes, and index pointers are of size 4 bytes. Given this scenario, what would be the best choice of the degree (i.e. the number of pointers per node) of the B+-tree?

  1. 16

  2. 42

  3. 43

  4. 44


Correct Option: D
Explanation:

Consider a relation scheme R = (A,B,C,D,E,H) on which the following functional dependencies hold: {A $\rightarrow$ B, C $\rightarrow$ D, E $\rightarrow$ C, D $\rightarrow$ A}

What are the candidate keys of R?

  1. AE,BE

  2. AE,BE,DE

  3. AEH,BEH,BCH

  4. AEH,BEH,DEH


Correct Option: D
Explanation:

R, (A, B, C, D) is a relation. Which of the following does not have a lossless join, dependency preserving BCNF decomposition?

  1. A $\rightarrow$ B, B $\rightarrow$ CD

  2. A $\rightarrow$ B, B $\rightarrow$ C, C $\rightarrow$ D

  3. AB $\rightarrow$ C, C $\rightarrow$ AD

  4. A $\rightarrow$ BCD


Correct Option: D
Explanation:

R(A,B,C,D) In options (1) & (2) there exists transitive functional dependency, so incorrect for BCNF. In option (3) AB $\rightarrow$ C C $\rightarrow$ AD So        AB $\rightarrow$ AD B $\rightarrow$ D In option (4) all the attributes depend on the same key in BCNF.

Relation R with an associated set of functional dependencies, F is decomposed into BCNF. The redundancy (arising out of functional dependencies) in the resulting set of relations is

  1. zero

  2. more than zero but less than that of an equivalent 3NF decomposition

  3. proportional to the size of F+

  4. indetermine


Correct Option: A
Explanation:

BCNF (Boyce Cold Normal Form) since R is decomposed in BCNF then no redundancy in the resulting set may occur and all transitive dependencies are removed.

Consider a relation geq which represents “greater than or equal to”, that is, (x,y) $\epsilon$geq only if y $\le$ x: Create table gaq (Ib integer not null ub integer not null primary key Ib foreign key (ub) references geq on delete cascade):

Which of the following is possible if a tuple (x,y) is deleted?

  1. A tuple (z,w) with z > y is deleted.

  2. A tuple (z,w) with z > x is deleted.

  3. A tuple (z,w) with w < x is deleted.

  4. The deletion of (x,y) is prohibited.


Correct Option: C
Explanation:

The relation book (title, price) contains the titles and prices of different books. Assuming that no two books have the same price, what does the following SQL query select? select title from book as B where ( select count(*) from book as T where T. price>B.Price)<5

  1. Titles of the four most expensive books

  2. Title of the fifth most inexpensive book

  3. Title of the fifth most expensive book

  4. Titles of the five most expensive books


Correct Option: D
Explanation:

This SQL query selects the titles of the five most expensive books by comparing with each other.

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 ($\sigma, \pi, \cup, \cap -$)?

  1. Department address of every employee

  2. Employee whose name is the same as its department name

  3. The sum of all employee salaries

  4. All employees of a given department


Correct Option: C
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.

- Hide questions