Q: 1 Consider following two instances of relations, X and Y:
| X | |
|---|---|
| Code | Item |
| 100 | A |
| 200 | B |
| 300 | B |
| 400 | C |
| Y | |
|---|---|
| Item | Quantity |
| A | 5 |
| B | 6 |
| C | 3 |
How many total tuples a Cartesian Product between the two relations X and Y will produce?
12
7
4
3
[ Option A ]
A Cartesian Product between two relations (tables) pairs every row of the first table with every row of the second table. So the total number of tuples is:
Total Tuples = (Number of tuples in X) × (Number of tuples in Y)
Here, Number of tuples in X = 4 and Number of tuples in Y = 3. This means every row of X will pair with every row of Y, producing 4×3 = 12 total tuples.
Q: 2 Which operation allows us to find tuples that are in one relation but are not in another relation?
Cartesian Product Operation
The Union Operation
The Set-Difference Operation
The Set Intersection Operation
[ Option C ]
In relational algebra, the set-difference operation (−) allows us to retrieve tuples that are present in one relation but not in another. It is written as R−S, returns all tuples that are in R but not in S.
This operation requires both relations to be Union-Compatible, meaning they must have the same set of attributes with compatible domains.
Q: 3 Let R1 and R2 be two relations with different attributes. What is the output of R1 U R2?
A relation with a combined schema of R1 and R2
Syntax error due to mismatched attributes
A Cartesian product
A view of all tuples from both
[ Option B ]
In relational algebra and SQL, the Union (U) operation combines tuples from two relations and removes duplicates. However, for a union operation to be valid, both relations must be Union-Compatible. Two relations are said to be union-compatible if they satisfy the following conditions:
If these conditions are not met, the union operation cannot be performed, and the system produces a Syntax Error.
Q: 4 Consider following two instances of relation Student and Faculty with operation on these instances –
| Student | |
|---|---|
| D-Name | Strength |
| CS | 900 |
| IT | 500 |
| Cyber | 300 |
| ME | 1000 |
| CIVIL | 2000 |
| Faculty | |
|---|---|
| D-Name | Strength |
| EE | 2000 |
| ECE | 5000 |
| Cyber | 300 |
| DS | 100 |
| CIVIL | 2000 |
(A) Student – Faculty
(B) (Student ∩ Faculty) ∪ (Faculty ∩ Student)
(C) (Student ∪ Faculty) – (Student ∩ Faculty)
(D) Student ∩ Faculty
Identify the correct option that produces equivalent output –
B,C,D
B,D
A,B
B,C
[ Option B ]
To find which operations give the same output, we first identify the common tuples in both relations. The only matching rows between Student and Faculty are Cyber (300) and CIVIL (2000). This means the intersection Student ∩ Faculty contains exactly these two tuples.
Now, expression (B) calculates (Student ∩ Faculty) ∪ (Faculty ∩ Student). Since both intersections are the same, their union also gives the same two tuples: Cyber (300) and CIVIL (2000). Expression (D) directly performs Student ∩ Faculty, which naturally results in the same pair of tuples. Hence, B and D produce identical outputs.
Q: 5 Consider Relation R1 and R2 as given below –
| R1(P,Q,R) | ||
|---|---|---|
| P | Q | R |
| p | q | r |
| k | i | j |
| m | q | r |
| d | e | f |
| R2(Q,R,S) | ||
|---|---|---|
| Q | R | S |
| q | r | n |
| l | c | o |
| q | r | a |
| q | r | b |
| e | f | g |
The number of tuples in output of R1 ⋈ R2 will be –
20
5
6
7
[ Option D ]
A Join is a relational database operation that combines rows from two tables based on a related attribute. It helps in retrieving connected information stored across multiple tables.
Among different types of joins, the Natural Join is a special type that automatically matches rows based on all columns with the same name and then merges them, removing duplicate columns in the output.
In this question, the natural join between R1 and R2 is performed on the common attributes Q and R. First, we identify matching pairs. In R1, the pairs (q, r) appear twice, and in R2, the same pair appears in three different rows. Each matching pair from R1 combines with all matching rows in R2, giving 2×3=6 tuples.
Additionally, the pair (e, f) in R1 matches one row in R2, giving 1 more tuple. The other pair (i, j) has no match, so it contributes zero. Adding them together, the Natural Join produces 6+1+0 = 7 tuples.
Q: 6 Which of the following is not a valid heuristic used in relational query optimization?
Perform selection operations as early as possible.
Apply projections early to reduce the number of columns.
Avoid Cartesian products whenever possible.
Apply projections as late as possible to retain all attributes.
[ Option D ]
In Relational Query Optimization, heuristics are used to reduce the size of intermediate results and improve efficiency. Standard heuristics include performing selection operations as early as possible, applying projections early to reduce columns, and avoiding Cartesian products.
Applying Projections Late is contrary to optimization principles because it increases the number of attributes in intermediate results, leading to higher computational cost.
Q: 7 Which operation requires two relations as input to form a new relation and these two relations must have a common attribute?
Division operation
Cartesian product operation
Natural join operation
Projection operation
[ Option C ]
The operation that requires two relations as input and needs these two relations to have a common attribute to form a new relation is the Natural Join operation.
Natural join automatically joins two relations based on all attributes with the same name and compatible data types in both relations. It matches and combines rows where the common attribute values are equal.
Relation Student:
| RollNo | Name |
|---|---|
| 1 | Suresh |
| 2 | Salman |
| 3 | Ramesh |
Relation Marks:
| RollNo | Marks |
|---|---|
| 1 | 85 |
| 2 | 90 |
| 4 | 75 |
Natural Join (Student ⋈ Marks) : The join matches rows where RollNo is common.
| RollNo | Name | Marks |
|---|---|---|
| 1 | Suresh | 85 |
| 2 | Salman | 90 |
Q: 8 In context of expression equivalence rules used for query optimization in DBMS, choose the false statement.
The set operations union and intersection are commutative.
The set operations union and intersection are not associative.
The projection operation distributes over the union operation.
The set difference operation is not commutative.
[ Option B ]
In query optimization, expression equivalence rules help the DBMS simplify queries without changing their final result. Some operations like union (∪) and intersection (∩) are both commutative and associative.
The Projection (π) operation distributes over union, meaning π(A ∪ B) = π(A) ∪ π(B).
The Set Difference (−) is not commutative because A − B ≠ B − A.
Q: 9 The result of a relational algebra operation is of which type?
Row
Attribute
Relation
Operation
[ Option C ]
In relational algebra, every operation such as SELECT, PROJECT, UNION, JOIN, etc. takes one or more relations as input and produces a new relation as output. This property is known as closure, which allows operations to be nested.
Q: 10 Which of the operations constitute a basic set of operations for manipulating relational data?
Predicate Calculus
Relational Calculus
Relational Algebra
None of these
[ Option C ]
Relational algebra is a set of basic operations used to manipulate data in relational databases. These includes:
These operations take relations as input and produce new relations as output, forming the foundation for querying data efficiently and systematically.
Q: 11 In tuple relational calculus P1 → P2 is equivalent to—
¬P1˅P2
P1˅P2
P1˄P2
P1˄¬P2
[ Option A ]
Q: 12 In context with Relational Algebra, which of the following are Unary Operators?
1. Select
2. Project
3. Union
4. Product
1 and 3 only
2 and 4 only
1 and 2 only
All are binary
[ Option C ]
Unary operators operate on a single relation (table) and produce a relation as output.
Binary operators work on two relations (tables) and produce a new relation as output.
Q: 13 Which of the following operations is not used in relational algebra?
Select
Set difference
Rename
Grouping
[ Option D ]
Relational algebra provides a set of basic operations used to manipulate relations:
The grouping commonly associated with SQL (GROUP BY) and aggregate functions.
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.