Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Database Management System

Refer below to answer the questions (Q.1 to Q4):

Branch_scheme=(Branch_name,assets,Branch_city)
Customer_scheme=(Customer_name,street,Customer_city)
Deposit_scheme=(Branch_name,account_number,Customer_name,balance)
Borrow_scheme=(Branch_name,loan_number,Customer_name,amount)
Client_scheme=(Customer_name,banker_name)

1. Using relational algebra, the query that finds customers who have a balance of over 1000 is:

(a) Πcustomer_name (σbalance > 1000 (Deposit)) (b) σcustomer_name (Пbalance > 1000 (Deposit))
(c) Пcustomer_name (σbalance > 1000 (Borrow)) (d) σcustomer_name (Пbalance > 1000 (Borrow))

2. Which of the following queries finds the clients of banker Agassi and the city they live in?

(a) ПClient.Customer_name.Customer_city (σClient.Customer_name=Customer.Customer_name)


(σBanker_name= ”Agassi” (Client × Customer))
(b) ПCustomer_name.Customer_city (σBanker_name= “Agassi” (Client × Customer)
(c) ПClient.Customer_name.Customer_city (ПBanker_name= “Agassi” (σClient.Customer_name=Customer.Customer_name
(Client × Customer)
(d) ПCustomer_name, Customer_city (σBanker_name= “Agassi” (Client × Customer)

3. Which of the following tuple relational calculus finds all customers who have a loan
amount of more than 1200?

(a) { t (Customer_name) | t ϵ Borrow ⋂ t [amount] > 1200}


(b) { t | t (Customer_name) ϵ Borrow ⋂ t [amount] > 1200}
(c) {t | ⋺ > ϵ Borrow ( t [Customer_name] = s [Customer_name] ⋂ s[amount] > 1200}
(d) None of the above

4. Which of the following Domain relation calculus finds all customers who have a loan
amount of over 1200?

(a) { <c> | ⋺ b, 1, a (<b, 1, c, a> ϵ borrow ⋃ a > 1200)}

1
(b) { <c> | ⋺ b, 1, a (<b, 1, c, a> ϵ borrow ⋂ a > 1200)}
(c) { <c> | ⋺ <b, 1, c, a> ϵ borrow ⋂ a > 1200)}
(d) { <c> | <b, 1, c, a> ϵ borrow ⋂ a > 1200)}

5. Which of the following features are beyond the capacity of relational algebra?

(a) Aggregate computation (b) Multiplication


(c) Finding transitive closure (d) All of the above

6. Which of the following is true?

(a) Relational algebra and relational calculus are both procedural query languages.
(b) Relational algebra and relational calculus are both non-procedural query languages.
(c) Relational algebra is a procedural query language and relational calculus is a non-
procedural query language.
(d) Relational algebra is a non-procedural query language and relational calculus is a
procedural query language.

7. If P and Q are predicates, P is the relational algebra expression, other which of the
following equivalents are valid?

(a) σP (σQ (e)) = σQ (σP (e))


(b) σP (σQ (e)) = σP⋂Q (e))
(c) σQ (σP (e)) = σP⋂Q (e))
(d) All of the above

8. Information about a collection of students is given by the relation StudInfo (StudId,


name, sex). The relation enroll (studId, course Id) gives which student has enrolled for
(or taken) what course (s). Assume that every course is taken by at least one male and at
least one male and at least one female student.

What does the following relational algebra expression represent?


ПcourseID ((ПstudID(σsex=”female” (studInfo) × Пcourse ID (enroll)) -enroll)

(a) Courses in which all the female students are enrolled.


(b) Courses in which a proper subset of female students are enrolled.
(c) Courses in which only male students are enrolled.

2
(d) None of the above.

9. Consider the relation employee (name, sex, supervisorName)


With name as the key, supervisorName gives the name of the supervisor of the employee
under consideration. What does the following tuple relational calculus query produce?

{e.name| employee (e) ⋂ ( ⩝x) [┐employee (x) ⋃ x.supervisorName≠e.name ⋃ x.sex=


“male”]}

(a) Name of employees with a male supervisor


(b) Name of employees with no immediate male subordinates
(c) Name of employees with no immediate female subordinate
(d) Name of employees with a female supervisor

10. Select the relational expression which could possibly return the following result:

a c
1 2
2 3

(a) Пa,c (σa=cR) (b) Пa<c (σa,c R)


(c) Пa>2 R (d) σa<c (Пa,c R)

11. Consider a banking database with the following table with 3 attributes (br_name, loan_no,
amount). Find the appropriate query for the given statement below.Find the loan no. for each
loan of an amount greater than 20,000.

(a) {t | t ϵ loans ⋂ t [amount] > 20,000} where ‘t’ is a tuple.


(b) {t | ⋺ s ϵ loans (t [loan_no] = s[loan_no] ⋂ [amount] > 20,000}
(c) {t | ⩝s ϵ loans (t [loans_no]= s[loan_no]⋂[amount] > 20,000}
(d) None of the above

12. Let r and s be 2 relations over the relation schemes R and S respectively and let A be an
attribute in R. Then the relational algebra expression,

σA=a (r⨝s) is always equal to:

3
(a) σA=a(r) (b) r
(c) σA=a(r) ⨝s (d) None of the above

13. Which of the following is wrong?

(a) ПL1⋃L2 (E1 ⨝ѳ E2)= (ПL1(E1)) ⨝ѳ (ПL2(E2))


(b) σρ(E1-E2) = σρ(E1) –E2
(c) σѳ1⋂ѳ2 (E) = σѳ1(σѳ2(E))
(d) None of the above

14. 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?

(a) List all vertices adjacent to a given vertex


(b) List all vertices which have self loops
(c) List all vertices which belong to cycles of less than 3 vertices
(d) List all vertices which reachable from a given vertex

15. Which of the following query transformation (i.e. replacing the LHS expression by the RHS
expression) is incorrect?

R1 and R2 are relation, C1, C2 are relation condition and A1, A2 are attributes of R1.

(a) ПA2 (σC1 (R1)) → σC1 (ПA2 (R1))


(b) σC1 (ПA1 (R1)) → ПA1 (σC1 (R1))
(c) σC1 (R1⋃R2) → σC1 (R1) ⋃ σC1 (R2)
(d) σC1 (σC1 (R1)) → σC2 (σC2 (R2))

16. Consider the relation (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?

Пname (σsex=”female” (Student)) – Пname (Student ⨝ sex=”female”⋂ x=Male ⋂ marks≤ m) ρn,x,m(Student))

(a) Names of girl students with the higher marks


(b) Names of girl students with more marks than some boy student
(c) Names of girl students with marks not less than some boy student

4
(d) Names of girl students with more marks than all the boy students

17. Which is the optimized version of the relational algebra expression:

ПA1(ПA2(σF1(σF2(r))) where A1, A2 are sets of attributes in r with A1< A2 and F1, F2 are
Boolean expression based on attributes in r?

(a) ПA1(σF1⋂F2(r)) (b) ПA1(σ(F1⋃F2)(r))


(c) ПA2(σ(F1⋂F2)(r)) (d) ПA2(σ(F1⋃F2)(r))

18. Consider the relation 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⨝(empId=eId)⋂(empAge < depAge)dependent)

The above query evaluates to the set of empIds of employees whose age is greater than that
of:

(a) Some dependents


(b) All dependents
(c) Some of his/ her dependents
(d) All of his/ her dependents

Common Data Question: Q.19 and Q.20

Consider the following relations A, B and C:

A:
Id Name Age
12 Arun 60
15 Shreya 24
99 Rohit 11

5
B:
Id Name Age
15 Shreya 24
25 Hari 4
98 Rohit 20
99 Rohit 11

C:
Id Name Age
10 2200 2
99 2100 1

19. How many tuples does the result of the following relation algebra expression contain?
Assume that the schema of A⋃B is the same as that of A:

(A⋃B)⨝A.Id> 40⋃C.Id<15C

(a) 7 (b) 4
(c) 5 (d) 9

20. Suppose R1(A, B) and R2(C, D) are 2 relation schemas. Let r1 and r2 be the corresponding
relation instances. B is a foreign key that refers to C in R2. If data in r1 and r2 satisfy
referential integrity constraints, which of the following is always true?

(a) ПB(r1) – ПC(r2) = ϕ


(b) ПC(r2)- ПB(r1) = ϕ
(c) ПB(r1) – ПC(r1) ≠ ϕ
(d) ПB(r1) – ПC(r2) ≠ ϕ

You might also like