This section contains carefully selected MCQs and Previous Year Questions with explanations to help students understand concepts and prepare effectively for examinations, interviews, and competitive tests.
Q: 1Consider 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?
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: 2Which operation allows us to find tuples that are in one relation but are not in another relation?
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: 3Let R1 and R2 be two relations with different attributes. What is the output of R1 U R2?
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: 4Consider 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 –
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: 5Consider 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 –
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: 6Which of the following is not a valid heuristic used in relational query optimization?
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: 7Which operation requires two relations as input to form a new relation and these two relations must have a common attribute?
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: 8In context of expression equivalence rules used for query optimization in DBMS, choose the false statement.
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: 9To be considered minimally relational, the DBMS should support which of the following relational functions?
Option A
For a DBMS to be considered minimally relational, it must support the basic operations of relational algebra. The most fundamental operations are SELECT, PROJECT, and JOIN.
Q: 10Consider the following relation schema of students.
STUDENT (Rollno, Name, DOB, Marks, Gender)
Which of the given query is equivalent to this query in English? “Find the tuples of student having marks above 80”.
Option A
In relational algebra, the Selection operation is represented by the symbol σ (sigma). It is used to select rows (tuples) from a relation that satisfy a given condition.
The given query says “Find the tuples of student having marks above 80”. This means we need to select those rows where Marks>80.
The selection operation is written as: σMarks>80(STUDENT)
Q: 11The result of a relational algebra operation is of which type?
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: 12Which of the operations constitute a basic set of operations for manipulating relational data?
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: 13In tuple relational calculus P1 → P2 is equivalent to—
Option A
Q: 14In context with Relational Algebra, which of the following are Unary Operators?
1. Select
2. Project
3. Union
4. Product
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: 15Write the name of the relational algebra operation as per the given order of their notation.
π, ×, σ
Option B
Relational algebra is a Procedural Query Language used in DBMS to perform operations on relations (tables). Different symbols represent different operations.
The symbol π represents the Projection operation. It is used to select specific columns (attributes) from a table.
E.g.:
The symbol × represents the Cartesian Product operation. It combines every row of one table with every row of another table.
The symbol σ represents the Selection operation. It is used to select rows that satisfy a given condition.
E.g.:
| SYMBOL | NAME | USED FOR |
|---|---|---|
| σ | Selection | Selects rows satisfying a condition. |
| π | Projection | Selects specific columns. |
| × | Cartesian Product | Combines all rows of two relations. |
| ∪ | Union | Combines tuples from two relations. |
| − | Set Difference | Returns tuples present in first relation but not in second. |
| ∩ | Intersection | Returns common tuples from two relations. |
| ÷ | Division | Finds values related to all tuples of another relation. |
| ⨝ | Join | Combines related tuples from two relations. |
| = | Equi Join Condition | Join based on equality condition. |
| ⟕ | Left Outer Join | Returns all rows from left relation and matching rows from right relation. |
| ⟖ | Right Outer Join | Returns all rows from right relation and matching rows from left relation. |
| ⟗ | Full Outer Join | Returns all matching and non-matching rows from both relations. |
| ρ | Rename | Renames relation or attributes. |
| ← | Assignment | Assigns result to a relation. |
| ∞ | Natural Join | Automatically joins relations using common attributes. |
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.