Dbms S9
Dbms S9
Dbms S9
(Solutions)
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))
Refer videos.
2. Which of the following queries finds the clients of banker Agassi and the city they live in?
3. Which of the following tuple relational calculus finds all customers who have a loan
amount of more than 1200?
1
Refer the videos.
4. Which of the following Domain relation calculus finds all customers who have a loan
amount of over 1200?
5. Which of the following features are beyond the capacity of relational algebra?
(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?
2
(d) All of the above
10. Select the relational expression which could possibly return the following result:
a c
1 2
2 3
3
(a) Пa,c (σa=cR) (b) Пa<c (σa,c R)
(c) Пa>2 R (d) σa<c (Пa,c R)
As we can see both entries of (a < c) also for selecting the entries we have to project
on 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.
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,
4
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?
Relational algebra will face problems when while calculating the length of cycle
self loops come, then the query could execute in one tuple only.
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.
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?
5
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?
Since, A1<A2, final relation L1L2 displaying values for attributes present in set A1.
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)
The above query evaluates to the set of empIds of employees whose age is greater than that
of:
Solution: Option ( )
A:
Id Name Age
12 Arun 60
15 Shreya 24
99 Rohit 11
6
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
The resultant table will have 7 tuples, with Id: 12, 15, 99, 98, 98, 25.
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?
ПB (r1) ≤ ПC (r2)