Database miscellaneous
- Consider a join (relation algebra) between relations r (R)and s (S) using the nested loop method. There are 3 buffers each of size equal to disk block size, out of which one buffer is reserved for intermediate results. Assuming size (r (R))< size(s (S)), the join will have fewer number of disk block accesses if
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
NA
- Consider the relational schema given below, where eId of the relation dependent is a foreign key referring to empId of the relation employee. Assume that every employee has at least one associated dependent in the dependent relation. employee (empId, empName, empAge) dependent(depId, eId, depName, depAge) Consider the following relational algebra query :
ΠempId (employee)- ΠempId (employee|X| (empId = eID)^.(empAge. depAge)dependent)
The above query evaluates to the set of empIds of employees whose age is greater than that of
-
View Hint View Answer Discuss in Forum
A gives the set of empIds of those employees whose age is less than or equal to the age of some of his/her dependents. Set of empIds of all employees - set of empIds obtained from part A gives the set of empIds of employees whose age is greater than that of all of his/ her dependents.Correct Option: D
A gives the set of empIds of those employees whose age is less than or equal to the age of some of his/her dependents. Set of empIds of all employees - set of empIds obtained from part A gives the set of empIds of employees whose age is greater than that of all of his/ her dependents.
- Consider the relation enrolled (student, course) in which (student, course) is the primary key, and the relation paid (student, amount) where student is the primary key. Assume no null values and no foreign keys or integrity constraints. Assume that amount 6000, 7000, 8000, 9000 and 10000 were each paid by 20% of the students. Consider these query plans (Plan1 on left, Plan2 on right) to “list all courses taken by students who have paid more than x”:
A disk seek takes 4 ms, disk data transfer bandwidth is 300 MB/s and checking a tuple to see if amount is greater than x takes 10 µs. Which of the following statements is correct?
-
View Hint View Answer Discuss in Forum
Given that left hand side is plan1 and right hand side is plan2 .
Plan1
1. select records form paid
2. joins them
Plan2
1. joins records from paid
2. records are checked
The seek time of disk is 4 ms and data transfer rate is 300 MB/s.
So, if x = 5000. Although the output remains the same but the plan1 executes faster than plan2 for all databases.Correct Option: C
Given that left hand side is plan1 and right hand side is plan2 .
Plan1
1. select records form paid
2. joins them
Plan2
1. joins records from paid
2. records are checked
The seek time of disk is 4 ms and data transfer rate is 300 MB/s.
So, if x = 5000. Although the output remains the same but the plan1 executes faster than plan2 for all databases.
- Let r be a rational instance with schema R = (A, B, C, D). We define r1 = ΠA, B, C(r) and r2 = ΠA, D(r). Let s = r1 * r2 where * denotes natural join. Given that the decomposition of r into r1 and r2 is lossy, which one of the following is true?
-
View Hint View Answer Discuss in Forum
R = (A, B, C, D)
r1 = ΠA , B , C (R) and r2 = ΠA , D (r)
s = r1 * r2
The tuples in s are more than that of r. Also, s consists of all the tuples of r along with other tuples. Therefore, the most appropriate relation is r ⊂ s .Correct Option: C
R = (A, B, C, D)
r1 = ΠA , B , C (R) and r2 = ΠA , D (r)
s = r1 * r2
The tuples in s are more than that of r. Also, s consists of all the tuples of r along with other tuples. Therefore, the most appropriate relation is r ⊂ s .
- Let R1 (A, B, C) and R2 (D, E) be two relational sachemas, where the primary keys are shown underlined, and let C be a foreign key in R1 referring to R2. Suppose there is no violation of the above referential integrity constraint in the corresponding relational instances r1 and r2 .Which one of the following relational algebra expressions would necessarily produce an empty relation?
-
View Hint View Answer Discuss in Forum
C is an attribute in R1 but D is a key in K2.
So consider ΠC (r1) – ΠD (r2)
So the result of this query would be all those tuples
which are in ΠC (r1) but not in ΠD (r2). Since D is a key so it has all the possible values of C. So difference would always be empty. Hence (b) is correct.Correct Option: B
C is an attribute in R1 but D is a key in K2.
So consider ΠC (r1) – ΠD (r2)
So the result of this query would be all those tuples
which are in ΠC (r1) but not in ΠD (r2). Since D is a key so it has all the possible values of C. So difference would always be empty. Hence (b) is correct.