Relational Algebra · Databases
31 questions · asked in 19 of 27 years (2000–2026)
MCQ 27 · MSQ 1 · NAT 31-mark 17 · 2-mark 14
2000Questions per year2026
Questions 1–5 of 31
The relation schema, Person(pid,city), describes the city of residence for every person uniquely identified by pid. The following relational algebra operators are available: selection, projection, cross product, and rename.
To find the list of cities where at least 3 persons reside, using the above operators, the minimum number of cross product operations that must be used is
To find the list of cities where at least 3 persons reside, using the above operators, the minimum number of cross product operations that must be used is
Answer: (B)
There is no aggregation here. So "at least 3 persons in a city" means we must find 3 different pids that share the same city. For this, one tuple must hold 3 copies of Person:
Here cond is: P1.city = P2.city = P3.city, and P1.pid, P2.pid, P3.pid are all different.
To combine 3 copies we need 2 cross products. With just one cross product, we can compare only 2 tuples.
Answer: 2
Here cond is: P1.city = P2.city = P3.city, and P1.pid, P2.pid, P3.pid are all different.
To combine 3 copies we need 2 cross products. With just one cross product, we can compare only 2 tuples.
Answer: 2
Consider the following three relations in a relational database.
Which of the following relational algebra expressions return the set of who own all the brands?
Which of the following relational algebra expressions return the set of who own all the brands?
One or more options are correct.
Answer: (A), (B)
"Owns all brands" is a division by the set of all brands. An employee qualifies if the pair (employee, brand) is in Own for every brand.
(A) is exactly this division. TRUE.
(B) gives every (owner, brand) pair. Subtracting leaves the pairs where the employee does not own that brand. Projecting to gives the employees who miss at least one brand. Removing them from leaves the employees who own every brand. This is the expanded form of division. TRUE.
(C) It divides by , the brands owned by someone, not by all brands. If some brand is owned by nobody, an employee who owns every owned brand is returned although he does not own all brands. WRONG.
(D) The dividend pairs every owner with every owned brand. Dividing by returns all owners if every brand is owned by someone, and the empty set otherwise. It does not depend on who owns what. WRONG.
Answer: (A), (B)
(A) is exactly this division. TRUE.
(B) gives every (owner, brand) pair. Subtracting leaves the pairs where the employee does not own that brand. Projecting to gives the employees who miss at least one brand. Removing them from leaves the employees who own every brand. This is the expanded form of division. TRUE.
(C) It divides by , the brands owned by someone, not by all brands. If some brand is owned by nobody, an employee who owns every owned brand is returned although he does not own all brands. WRONG.
(D) The dividend pairs every owner with every owned brand. Dividing by returns all owners if every brand is owned by someone, and the empty set otherwise. It does not depend on who owns what. WRONG.
Answer: (A), (B)
A relation in a relational database has 1200 tuples. The attribute has integer values ranging from 6 to 20, and the attribute has integer values ranging from 1 to 20. Assume that the attributes and are independently distributed.
The estimated number of tuples in the output of is ____________
The estimated number of tuples in the output of is ____________
Answer: 820
Estimate the fraction of tuples that pass the condition, then multiply by the number of tuples.
- has 15 values (6 to 20). The values 11 to 20 satisfy , so .
- has 20 values, so .
- and are independent, so
Estimated tuples in the output: .
(Counting the different value pairs that satisfy the condition, , does not give the number of tuples.)
Answer: 820
- has 15 values (6 to 20). The values 11 to 20 satisfy , so .
- has 20 values, so .
- and are independent, so
Estimated tuples in the output: .
(Counting the different value pairs that satisfy the condition, , does not give the number of tuples.)
Answer: 820
The following relation records the age of 500 employees of a company, where empNo ( indicating the employee number) is the key:
Consider the following relational algebra expression:
What does the above expression generate?
Consider the following relational algebra expression:
What does the above expression generate?
Answer: (C)
The join matches each employee with every employee who is younger (age age1). An employee shows up in the result if at least one other employee is younger. This means that their age is not the minimum.
Answer: Employee numbers of all employees whose age is not the minimum
Answer: Employee numbers of all employees whose age is not the minimum
Consider the following relation P(X, Y, Z), Q(X, Y, T) and R(Y, V):
How many tuples will be returned by the following relational algebra query?
Answer:______
How many tuples will be returned by the following relational algebra query?
Answer:______
Answer: 1
Left part: The tuples of R with V = V2 are (Y3, V2) and (Y2, V2). In P, only (X2, Y2, Z2) has Y = Y2 {X2}.
Right part: The tuples of Q with T 2 are (X1, Y2, 5) and (X1, Y1, 6). Both Y2 and Y1 are present in R {X1}.
Now take {X2} {X1}. This gives {X2} 1 tuple.
Answer: 1
Right part: The tuples of Q with T 2 are (X1, Y2, 5) and (X1, Y1, 6). Both Y2 and Y1 are present in R {X1}.
Now take {X2} {X1}. This gives {X2} 1 tuple.
Answer: 1
Keep practising
Topics in Databases
ER ModelRelational Schema
Relational AlgebraYou are here
Tuple CalculusSQLIntegrity ConstraintsNormal FormFile SystemTransaction