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: 3
Match the following:
| List—1 | List—2 |
|---|---|
| I. Relational Algebra | P. Non-Procedural Query Language |
| II. Relational Calculus | Q. Procedural Query Language |
| III. Generalization | R. Top-Down Approach |
| IV. Specialization | S. Bottom-Up Approach |
Option B
A Database Management System (DBMS) provides different query languages to retrieve and manipulate data. It also provides Enhanced Entity-Relationship (EER) concepts, such as Generalization and Specialization, to design complex database schemas.
| List-I | Correct Match | Reason |
|---|---|---|
| Relational Algebra | Procedural Query Language | Relational algebra is a procedural query language because it specifies what operations to perform and how to perform them to retrieve the required data. |
| Relational Calculus | Non-Procedural Query Language | Relational Calculus is a non-procedural (declarative) query language because it specifies what data is required, without describing how to retrieve it. |
| Generalization | Bottom-Up Approach | Generalization combines multiple lower-level entities having common features into a single higher-level entity. Therefore, it follows a Bottom-Up approach. |
| Specialization | Top-Down Approach | Specialization divides a higher-level entity into multiple lower-level entities based on their distinguishing characteristics. Therefore, it follows a Top-Down approach. |
Q: 4Let 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: 5Consider 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: 6Consider 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: 7Which 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: 8Which 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: 9In 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: 10To 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: 11Consider 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: 12The 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: 13Which 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: 14In tuple relational calculus P1 → P2 is equivalent to—
Option A
Q: 15In 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.
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.