Database Questionsand Answer
Database Questionsand Answer
1. What is a database and how does it differ from a traditional file system?
Answer B
2. Define a Database Management System (DBMS) and list its key functions.
- A) A DBMS is a software for managing databases and its key functions include data storage, retrieval,
and update.
Answer A
Answer D
- D) A NoSQL database.
Answer C
5. What is SQL?
- A) A programming language.
- C) A type of hardware.
- D) An operating system.
Answer B
6. Write a SQL query to create a table named "Students". Which option is correct?
- A) CREATE STUDENTS;
Answer D
7. How would you retrieve all records from a table named "Employees" where the "Department" is
"HR"?
Answer B
8. What is normalization?
Answer B
- B) Consistency
- C) Independence
- D) Distribution
Answer B
- A) INSERT
- B) UPDATE
- C) DELETE
- D) SELECT
Answer B
Answer C
- A) NOT EMPTY
- B) UNIQUE
- C) DUPLICATE
- D) DISTINCT
Answer B
Answer A
Answer B
Answer C
- C) A database constraint.
- D) A type of attribute.
Answer A
- C) A composite attribute.
- D) A derived attribute.
Answer A
Answer D
Answer B
- A) Each entity in the relationship is related to one and only one other entity.
- B) An entity in the relationship can be related to multiple entities in the other set.
Answer B
- D) A derived relationship.
Answer C
Answer B
Answer A
Answer B
Answer B
- A) With a rectangle.
- B) With a diamond.
- C) With an oval.
- D) With a triangle.
Answer B
Answer B
Answer B
15. What is the difference between `INNER JOIN` and `OUTER JOIN` in SQL?
- A) INNER JOIN returns matched rows from both tables, while OUTER JOIN returns all rows from one
table.
- B) INNER JOIN returns all rows from both tables, while OUTER JOIN returns only matched rows.
- C) `INNER JOIN` returns matched rows from both tables, while `OUTER JOIN` returns matched rows
plus unmatched rows from one or both tables.
- D) INNER JOIN only returns rows from one table, while OUTER JOIN returns rows from both tables.
Answer C
1. Which of the following best describes the concept of a "superkey" in a relational database?
- C) A set of attributes that can uniquely identify a tuple, not necessarily minimal.
Answer C
- B) A minimal superkey.
- C) A primary key.
Answer B
3. In the context of relational databases, what does the "referential integrity constraint" ensure?
- C) Foreign key values must match primary key values in the referenced table or be null.
Answer C
4. Which normal form requires that a relation has no partial dependency on a candidate key?
Answer B
- A) A functional dependency between two non-key attributes via the primary key.
Answer C
6. Which normal form is considered a stricter version of the Third Normal Form (3NF)?
Answer A
7. What is the main goal of achieving Boyce-Codd Normal Form (BCNF) in relational database design?
Answer C
- B) A constraint that ensures a value in one table must match a value in another table.
Answer A
10. In which normal form is a relation if it is in 2NF and every non-key attribute is non-transitively
dependent on the primary key?
Answer B
11. Which of the following is true about a relation in Boyce-Codd Normal Form (BCNF)?
Answer D
12. What is the primary purpose of a primary key constraint in a relational database?
Answer C
13. Which of the following normal forms eliminates the possibility of insert, update, and delete
anomalies?
Answer C
- B) A constraint that requires that a set of values in one relation must be a subset of values in another
relation.
- C) A dependency that arises when an attribute depends on another attribute through transitivity.
Answer A
Answer C
16. In a relational database, what does the term "lossless join" refer to?
- C) A property ensuring that decomposing a relation into two relations and then joining them back
results in the original relation.
Answer C
17. Which of the following is a reason to use normalization in relational database design?
Answer B
- A) A normal form that ensures all constraints on the data are a logical consequence of the definition
of keys and domains.
- C) A normal form that ensures all attributes are fully functionally dependent on the primary key.
Answer A
19. Which normal form is concerned with the removal of join dependencies?
Answer D
Answer B
Basic Concepts
1. What are the key differences between a relational database and a NoSQL database?
- B) Relational databases use tables with rows and columns, while NoSQL databases can use various
models like document, key-value, graph, or column-family.
Answer B
Answer A
- B) A unique identifier for a row in a table, ensuring that each record can be uniquely identified.
Answer B
- A) The process of designing a database to reduce redundancy and improve data integrity.
Answer A
- B) A clustered index can have multiple indexes per table, while a non-clustered index can only have
one.
- C) A clustered index is used for OLAP, while a non-clustered index is used for OLTP.
- D) A clustered index is created automatically, while a non-clustered index must be created manually.
Answer A
6. Write an SQL query to find all employees who earn more than the average salary.
- B) SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);
- D) SELECT * FROM employees HAVING salary > (SELECT AVG(salary) FROM employees);
Answer B
Answer A
8. Explain the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN.
- A) INNER JOIN returns only matched rows; LEFT JOIN returns matched rows and all rows from the left
table; RIGHT JOIN returns matched rows and all rows from the right table; FULL OUTER JOIN returns all
rows from both tables.
- B) INNER JOIN returns all rows from both tables; LEFT JOIN returns only matched rows; RIGHT JOIN
returns matched rows and all rows from the left table; FULL OUTER JOIN returns only matched rows.
- C) INNER JOIN returns matched rows and all rows from the right table; LEFT JOIN returns matched
rows and all rows from the left table; RIGHT JOIN returns only matched rows; FULL OUTER JOIN returns
all rows from both tables.
- D) INNER JOIN returns all rows from both tables; LEFT JOIN returns all rows from the left table; RIGHT
JOIN returns all rows from the right table; FULL OUTER JOIN returns only matched rows.
Answer A
- A) A query that retrieves data from multiple tables; used to combine results.
- B) A query that runs within another query; used to perform operations that require intermediate
results.
- D) A query that deletes data from a table; used to remove unwanted records.
Answer B
- C) By using indexes, reducing the number of columns in SELECT, and optimizing joins.
Answer C
- A) The process of merging multiple databases; it improves performance by reducing the number of
databases.
- B) The process of splitting a database into smaller, more manageable pieces; it improves
performance by distributing load across multiple servers.
- C) The process of compressing data in the database; it improves performance by reducing storage
requirements.
- D) The process of encrypting data in the database; it improves performance by enhancing security.
Answer B
12. Explain the concept of database replication and its types.
- A) The process of copying data from one database to another; types include synchronous and
asynchronous replication.
- B) The process of deleting data from a database; types include hard and soft deletion.
- C) The process of compressing data in a database; types include lossless and lossy compression.
- D) The process of merging data from multiple databases; types include full and partial merge.
Answer A
- A) It records all transactions and changes made to the database; helps in recovery and rollback.
- C) It deletes old data from the database; helps in maintaining database size.
Answer B
14. What are the differences between OLTP (Online Transaction Processing) and OLAP (Online Analytical
Processing)?
- A) OLTP is used for batch processing; OLAP is used for real-time processing.
- B) OLTP handles large volumes of data; OLAP handles small volumes of data.
- C) OLTP is designed for managing transaction-oriented applications; OLAP is designed for analytical
and decision-making applications.
Answer C
15. Describe the CAP theorem and its implications for distributed databases.
- A) Consistency, Availability, Partition Tolerance; a distributed system can achieve only two out of the
three.
- B) Compression, Availability, Performance; a distributed system can achieve only two out of the
three.
- C) Consistency, Accuracy, Performance; a distributed system can achieve only two out of the three.
- D) Consistency, Adaptability, Partition Tolerance; a distributed system can achieve only two out of
the three.
Answer A
- B. An entity that has its own unique key and does not depend on any other entity.
- C. An entity that cannot be uniquely identified by its own attributes alone and relies on a foreign key
from another entity.
- Answer: C
- Answer: C
3. Given an ER model with entities Author, Book, and Publisher, and the relationships Author writes
Book and Publisher publishes Book, what would be an appropriate primary key for the Book entity?
- A. BookID
- B. (AuthorID, PublisherID)
- C. (AuthorID, BookID)
- D. (PublisherID, BookID)
- Answer: A
4. Which of the following is NOT a characteristic of a good ER diagram?
- Answer: B
- B. By creating a new associative table that includes foreign keys from both related entities.
- Answer: B
- Answer: B
7. Consider the relation R(A, B, C, D) with the following functional dependencies: {A → B, B → C, C → D}.
What is the highest normal form that R satisfies?
- A. 1NF
- B. 2NF
- C. 3NF
- D. BCNF
- Answer: D
- Answer: B
9. Consider a relation schema R(A, B, C, D) with functional dependencies {A → B, C → D}. What is the key
for R?
- A. A
- B. C
- C. (A, C)
- D. (B, D)
- Answer: C
- A. A → B, B → A
- B. A →→ B means if two tuples have the same A value, then their B values are independent of each
other.
- C. A →→ B means B is a subset of A.
- Answer: B
11. Given a relation R(A, B, C) with functional dependencies {A → B, B → C}, which of the following
decompositions is a lossless-join decomposition?
12. Which of the following statements is true about 4NF (Fourth Normal Form)?
- Answer: A
- Answer: B
- A. An entity
- B. An attribute
- C. A relationship
- D. A primary key
- Answer: C
15. Which scenario best illustrates the use of a recursive relationship in an ER model?
- Answer: B
16. In ER modeling, which type of attribute can be broken down into smaller components?
- A. Composite attribute
- B. Multi-valued attribute
- C. Derived attribute
- D. Key attribute
- Answer: A
- Answer: B
18. Consider a relation R(A, B, C, D) with functional dependencies {A → B, A → C, B → D}. Which of the
following decompositions is in 3NF?
- Answer: A
19. Which of the following statements is true about the decomposition of a relation into 2NF?
- Answer: A
20. Given a relation schema R(A, B, C, D) with functional dependencies {A → B, C → D, B → C}, what is
the minimal cover for these FDs?
- A. {A → B, B → C, C → D}
- B. {A → B, A → C, A → D}
- C. {A → B, B → D}
- D. {A → B, C → D}
- Answer: A
- Answer: A
22. Consider a relation R(A, B, C) with the functional dependency A → B and A → C. If R is decomposed
into R1(A, B) and R2(A, C), which normal form does this decomposition achieve?
- A. 1NF
- B. 2NF
- C. 3NF
- D. BCNF
- Answer: C
23. Which of the following correctly defines a candidate key in a relation schema?
- Answer: A
24. In the context of normalization, what is the primary goal of moving a relation to 5NF?
B. To ensure every non-key attribute is fully functionally dependent on the primary key.
# Answer# A
25. Consider a relation R(A, B, C, D, E) with functional dependencies {A → B, C → D, D → E}. Which of the
following decompositions is in BCNF?
# Answer # B
26. Which of the following best describes the concept of a surrogate key in a database?
- Answer: C
- A. A derived attribute
- B. A composite attribute
- C. A multi-valued attribute
- D. A key attribute
- Answer: C
28. Which of the following normalization forms is concerned with eliminating transitive dependencies?
- A. 1NF
- B. 2NF
- C. 3NF
- D. BCNF
- Answer: C
- Answer: A
30. Which of the following is true for a relation that is in 2NF but not in 3NF?
- Answer: A
- A. A
- B. B
- C. C
- D. D
- Answer: B
32. In a relational database, what is a foreign key constraint?
- B. A rule that maintains referential integrity by ensuring that a foreign key value in one table
matches a primary key value in another table.
- Answer: B
- Answer: A
- Answer: C
36. What is the main advantage of using a surrogate key over a natural key?
- B. Surrogate keys are system-generated and ensure uniqueness without depending on actual data
values.
- Answer: B
37. Which of the following best describes a snowflake schema in a data warehouse?
- A. A schema where data is organized in a star-like structure with a central fact table and surrounding
dimension tables.
- B. A normalized version of a star schema where dimension tables are further divided into related
tables.
- Answer: B
38. Which of the following best describes the process of aggregation in ER modeling?
- Answer: B
- B. It ensures that every join dependency in the relation is implied by the candidate keys.
- D. It ensures that every non-key attribute is functionally dependent on the primary key.
- Answer: B
- A. A
- B. B
- C. C
- D. D
- Answer: A
1. Which of the following best describes the primary goal of physical database design?
- Answer: B
2. Which of the following strategies can help improve the performance of read-heavy databases?
- A. Normalization
- B. Indexing
- Answer: B
- B. To physically sort the data rows in the table according to the index key.
- D. Reduced normalization
- Answer: B
- B. A physical copy of the result set of a query, stored for fast access.
- D. A view that only stores the query definition, not the data.
- Answer: B
- Answer: C
7. Which of the following describes the purpose of using a RAID (Redundant Array of Independent Disks)
configuration in a database system?
- Answer: B
8. What is the main advantage of using columnar storage for a database table?
- C. Easier to normalize
- Answer: B
9. Which type of index is best suited for queries that filter on multiple columns?
- A. Unique index
- B. Single-column index
- C. Composite index
- D. Bitmap index
- Answer: C
- B. To increase the speed of data retrieval by storing frequently accessed data in memory.
- Answer: B
- B. Splitting a table into different tables with the same attributes but different rows.
- Answer: B
12. In physical database design, what is the purpose of using denormalization?
- Answer: B
13. Which of the following best describes the role of a database optimizer?
- Answer: B
- B. Improved security
- Answer: C
15. Which of the following is true about the use of SSDs (Solid State Drives) in database systems?
- B. SSDs provide faster read and write speeds than traditional HDDs.
- C. SSDs are more cost-effective than HDDs for large data volumes.
- Answer: B
16. What is the purpose of using data compression in physical database design?
- Answer: B
17. Which of the following describes the concept of sharding in a database system?
- B. Dividing a large database into smaller, more manageable pieces called shards, distributed across
multiple servers.
- Answer: B
18. Which of the following is a key consideration when choosing a storage engine for a database?
- Answer: B
19. What is the impact of increasing the block size in a database file system?
- Answer: A
20. Which of the following is a disadvantage of using RAID 0 (striping) in a database system?
- A. Increased data redundancy.
- Answer: C
21. Which of the following is a common technique to secure data at rest in a relational database?
- Answer: B
22. In database security, what is the primary purpose of using role-based access control (RBAC)?
- Answer: B
- Answer: B
24. Which of the following is NOT a common physical security measure for database servers?
- A. Implementing biometric access controls
- Answer: C
25. What is the primary benefit of using partitioning in physical database design?
- C. Increases redundancy
- Answer: B
26. Which of the following best describes the purpose of a RAID 5 configuration in a database system?
- Answer: C
27. In the context of physical database design, what is a hot spot, and why should it be avoided?
- B. A highly concentrated area of data access that can lead to I/O bottlenecks
- Answer: B
28. Which of the following indexing strategies is most suitable for a table with a high volume of insert
operations?
- A. Clustered indexing
- B. Non-clustered indexing
- C. Bitmap indexing
- D. Hash indexing
- Answer: D
- Answer: B
30. Which of the following scenarios would justify the use of denormalization?
- Answer: B
- Answer: B
32. In the context of database tuning, what is the purpose of query optimization?
- Answer: B
33. Which of the following tuning techniques involves restructuring SQL queries to improve
performance?
- A. Indexing
- B. Query rewriting
- C. Partitioning
- D. Data archiving
- Answer: B
34. In a relational database, what is the impact of increasing the size of database buffers?
- A. Reduces the need for disk I/O operations by storing more data in memory
- B. Increases the need for disk I/O operations by decreasing memory usage
- Answer: A
35. Which of the following is an advantage of using an SSD over an HDD for database storage?
- Answer: B
- Answer: B
37. Which of the following describes the role of a database load balancer?
- A. To distribute database queries across multiple servers to improve performance and reliability
- Answer: A
38. Which of the following describes the use of data sharding in a physical database design?
- Answer: B
39. In physical database design, which of the following is a benefit of using compression techniques?
- Answer: B
40. Which of the following is true about the use of database snapshots?
- A. Snapshots are real-time replicas of the database used for high availability.
- B. Snapshots are point-in-time copies of the database that can be used for backup and recovery.
Relational Algebra
1. Which of the following relational algebra operations is used to extract tuples from a relation that
satisfy a given predicate?
- A. Union (∪)
- B. Projection (π)
- C. Selection (σ)
- Answer: C
2. What is the result of performing the natural join operation on two relations R(A, B) and S(B, C)?
- B. A relation containing only tuples that have the same value for attribute B in both R and S
- D. A relation containing all tuples from R and the common tuples from S
- Answer: B
- A. Selection (σ)
- B. Intersection (∩)
- C. Union (∪)
- D. Projection (π)
- Answer: B
4. Consider two relations R(A, B) and S(B, C). Which relational algebra operation would you use to
combine these two relations on the attribute B?
- A. σ
- B. π
- C. ⨝ (Natural Join)
- D. ∪
- Answer: C
5. In relational algebra, what is the result of the division operation R ÷ S when R(A, B) and S(B) are given?
- A. A relation containing all tuples of A in R that are paired with every tuple in S
- B. A relation containing all tuples of B in S that are paired with every tuple in R
- D. An intersection of R and S
- Answer: A
- A. Projection (π)
- B. Selection (σ)
- C. Rename (ρ)
- D. Join (⨝)
- Answer: C
- A. Selection of tuples from relation R where the attribute A has a specific value
- Answer: B
8. Which of the following statements about the relational algebra union operation ( ∪) is true?
- B. It combines tuples from two relations with the same attribute names but different domains.
- Answer: A
- Answer: B
10. In relational algebra, which operation is used to eliminate duplicate tuples from a relation?
- A. Projection (π)
- B. Selection (σ)
- C. Union (∪)
- D. Difference (-)
- Answer: A
Relational Calculus
- C. It is procedural.
- Answer: A
12. In tuple relational calculus, how would you express a query to find all tuples t such that t[A] = 'Smith'
in relation R?
- B. σA='Smith'(R)
- C. πA='Smith'(R)
- D. {t | t ∈ R ∧ t[A] = 'Smith'}
- Answer: D
13. Which of the following is true about domain relational calculus (DRC)?
- A. It uses domain variables that take on values from the attributes' domains.
- Answer: A
14. In domain relational calculus, which of the following is the correct representation for finding all pairs
of (x, y) where x is from attribute A and y is from attribute B of relation R?
- Answer: D
15. Which of the following relational calculus expressions is used to find tuples in relation R where the
attribute A is greater than 10?
- B. σA>10(R)
- C. πA>10(R)
- Answer: A
16. In tuple relational calculus, how do you express a query to find all tuples t such that there is no tuple
u in relation R where t[A] = u[B]?
- B. σ¬∃u.B=A(R)
- C. π¬∃u.B=A(R)
- Answer: D
17. Which of the following is a key difference between relational algebra and relational calculus?
- B. Relational algebra specifies how to retrieve data, while relational calculus specifies what data to
retrieve.
- C. Relational calculus is used for updating data, while relational algebra is used for querying.
- Answer: B
18. Which of the following relational calculus expressions correctly represents the query to find all
tuples where attribute A equals 20 in relation R?
- C. {t | t ∈ R ∧ t[A] = 20}
- D. σA=20(R)
- Answer: A
19. In domain relational calculus, how is a query to find all values of x from attribute A of relation R
where x > 30 represented?
- A. {x | ∃R (x > 30)}
- Answer: C
20. In tuple relational calculus, how would you express a query to find all tuples t such that for some
tuple u in relation R, t[A] = u[B] and u[C] = 'Jones'?
- D. π∃u.B=A ∧ C='Jones'(R)
- Answer: A
Relational Algebra
1. Which of the following operations in relational algebra combines two relations and produces a new
relation containing tuples that are present in both input relations?
a) Selection
b) Projection
c) Cartesian Product
d) Outer Join
2. In relational algebra, which operation is used to select tuples from a relation that satisfy a certain
condition?
a) Projection
b) Outer Join
c) Selection
d) Aggregate
Answer: c) Selection
a) The resulting relation contains only selected attributes from the input relation
b) The resulting relation contains all attributes from the input relation
Answer: a) The resulting relation contains only selected attributes from the input relation
4. Which of the following relational algebra operations combines projection and selection?
a) Union
b) Intersection
c) Division
d) Natural Join
c) Combines tuples from two relations that do not satisfy a given condition
Answer: d) Combines tuples from two relations based on matching attribute values
6. Which of the following operations in relational algebra is used to combine tuples from two relations,
including those that do not have matching attribute values?
a) Natural Join
b) Inner Join
c) Outer Join
d) Division
c) Retrieves tuples from one relation that are associated with all tuples in another relation
Answer: c) Retrieves tuples from one relation that are associated with all tuples in another relation
a) MAX
b) UNION
c) DIFFERENCE
d) INNER JOIN
Answer: a) MAX
a) Combines only tuples with matching attribute values from two relations
b) Combines all tuples from two relations, filling in NULL values for non-matching tuples
c) Combines tuples from two relations that do not satisfy a given condition
d) Combines tuples from two relations based on a given condition, excluding non-matching tuples
Answer: b) Combines all tuples from two relations, filling in NULL values for non-matching tuples
11. Which relational algebra operation is used to combine tuples from two relations, keeping only the
tuples that appear in both relations?
a) Union
b) Intersection
c) Difference
d) Cartesian Product
Answer: b) Intersection
b) All attributes from the input relation are included in the result
c) Only distinct attribute values are retained in the result
d) The resulting relation contains all tuples from the input relation
13. What is the result of the set difference operation in relational algebra?
b) Tuples that appear in the first relation but not in the second relation
Answer: b) Tuples that appear in the first relation but not in the second relation
b) To retrieve tuples from one relation that are associated with all tuples in another relation
Answer: b) To retrieve tuples from one relation that are associated with all tuples in another relation
a) Projection
b) Difference
c) COUNT
d) Natural Join
Answer: c) COUNT
16. In relational algebra, what does the Cartesian product operation produce?
17. Which of the following set operations in relational algebra combines tuples from two relations while
eliminating duplicates?
a) Union
b) Intersection
c) Difference
d) Cartesian Product
Answer: a) Union
a) Only tuples with matching attribute values from both relations are retained
b) Tuples from both relations are retained, filling in NULL values for non-matching tuples
d) Only tuples from one relation are retained, excluding tuples from the other relation
Answer: b) Tuples from both relations are retained, filling in NULL values for non-matching tuples
19. Which of the following operations in relational algebra is used to combine tuples from two relations
based on common attribute values?
a) Difference
b) Intersection
c) Natural Join
d) Cartesian Product
22. Which of the following operations in relational algebra combines two relations and eliminates
duplicate tuples?
a) Union
b) Intersection
c) Difference
d) Cartesian Product
Answer: b) Intersection
23. When performing an outer join operation in relational algebra, which tuples are included in the
result?
b) Tuples from both relations, including NULL values for non-matching tuples
Answer: b) Tuples from both relations, including NULL values for non-matching tuples
24. What is the result of the set union operation in relational algebra?
c) Tuples that appear in the first relation but not in the second relation
d) All tuples from both input relations, eliminating duplicates
25. Which of the following is an example of an aggregate function that can be applied to a relation in
relational algebra?
a) Projection
b) Union
c) COUNT
d) Outer Join
Answer: c) COUNT
a) Retrieves tuples from one relation that are present in another relation
b) Retrieves tuples from one relation that are not present in another relation
c) Retrieves tuples from one relation that are associated with all tuples in another relation
Answer: c) Retrieves tuples from one relation that are associated with all tuples in another relation
b) Only common attributes from both relations are included in the result
c) Tuples with matching attribute values from both relations are retained
d) Tuples with non-matching attribute values from both relations are retained
Answer: c) Tuples with matching attribute values from both relations are retained
28. Which of the following operations in relational algebra combines tuples from two relations, retaining
only the tuples that appear in the first relation but not in the second relation?
a) Intersection
b) Difference
c) Union
d) Cartesian Product
Answer: b) Difference
29. In relational algebra, what is the purpose of the aggregate function AVG?
30. When applying the projection operation in relational algebra, what happens to duplicate tuples?
Additional questions
1. Consider two relations, Employees and Departments, with the following schemas and sample data:
Which relational algebra operation would be used to retrieve the names of all employees who work in
the 'Sales' department?
a) Selection
b) Projection
c) Natural Join
d) Outer Join
Explanation:
To retrieve the names of all employees who work in the 'Sales' department, we need to select tuples
from the Employees relation where the DeptID matches the DeptID of the 'Sales' department in the
Departments relation.
2. Consider two relations, Orders and Customers, with the following schemas and sample data:
Which relational algebra operation would be used to retrieve the names of all customers who have not
placed any orders?
a) Difference
b) Division
c) Outer Join
d) Projection
Explanation:
To retrieve the names of all customers who have not placed any orders, we need to find the set
difference between all customers and those who have placed orders.
Correct Answer: a) Difference
3. Consider two relations, Students and Courses, with the following schemas and sample data:
Which relational algebra operation would be used to retrieve the names of all students who are enrolled
in at least one course
a) Projection
b) Outer Join
c) Natural Join
d) Intersection
Explanation:
To retrieve the names of all students who are enrolled in at least one course, we need to perform a
natural join operation between the Students and Courses relations based on a common attribute such as
StudentID or CourseID.
4. Consider two relations, Employees and Departments, with the following schemas and sample data:
Which relational algebra operation would be used to retrieve the names of all departments with no
employees?
a) Difference
b) Projection
c) Outer Join
d) Intersection
Example Data:
Employees:
|-------|---------|--------|
|1 | Alice | 101 |
|2 | Bob | 102 |
|3 | Charlie | 101 |
|4 | David | 103 |
|5 | Eve | 102 |
Departments:
| DeptID | Name |
|--------|----------|
| 101 | Sales |
| 102 | Marketing|
| 103 | HR |
Answer: a) Difference
5. Consider two relations, Orders and Products, with the following schemas and sample data:
Orders (OrderID, ProductID, Quantity)
Which relational algebra operation would be used to retrieve the names of all products that have not
been ordered?
a) Outer Join
b) Intersection
c) Difference
d) Natural Join
Example Data:
Orders:
|---------|-----------|----------|
|1 | 101 |2 |
|2 | 102 |1 |
|3 | 103 |3 |
|4 | 101 |1 |
Products:
|-----------|----------|-------|
| 101 | Laptop | 1000 |
Answer: c) Difference
3. Consider two relations, Students and Grades, with the following schemas and sample data:
Which relational algebra operation would be used to retrieve the names of all students who have not
received any grades?
a) Outer Join
b) Projection
c) Difference
d) Intersection
Example Data:
Students:
| StudentID | Name |
|-----------|---------|
| 101 | Alice |
| 102 | Bob |
| 103 | Charlie |
| 104 | David |
Grades:
|-----------|----------|-------|
| 101 | 201 |A |
| 102 | 202 |B |
| 103 | 201 |B |
| 104 | 203 |A |
Answer: c) Difference
1: Consider a relation named "Employees" with attributes (EmpID, Name, Age, Department). Which of
the following relational algebra operations would be used to retrieve the names of all employees who
are younger than 30 years old?
a) Selection
b) Projection
d) Cross Product
Answer: a) Selection
2: Consider a relation named "Students" with attributes (StudentID, Name, Age) and another relation
named "Courses" with attributes (CourseID, Name, Credits). Which relational algebra operation would
be used to retrieve the names of all students along with their corresponding course names?
a) Projection
b) Inner Join
c) Outer Join
d) Cross Product
a) Cross Product
b) Outer Join
c) Inner Join
4: Consider a relation named "Orders" with attributes (OrderID, CustomerID, ProductID) and another
relation named "Customers" with attributes (CustomerID, Name, City). Which relational algebra
operation would be used to retrieve all orders along with the corresponding customer names?
a) Projection
b) Outer Join
c) Inner Join
5: Consider two relations, "Employees" and "Projects", with attributes (EmpID, Name) and (ProjectID,
ProjectName) respectively. Which relational algebra operation would be used to retrieve all
combinations of employees and projects?
a) Selection
b) Projection
c) Cross Product
d) Inner Join
6: Consider a relation named "Orders" with attributes (OrderID, CustomerID, ProductID) and another
relation named "Products" with attributes (ProductID, ProductName, Price). Which operation in
relational algebra would be used to retrieve orders along with the corresponding product names?
a) Projection
b) Outer Join
c) Inner Join
7:Consider two relations, "Students" and "Grades", with attributes (StudentID, Name) and (StudentID,
CourseID, Grade) respectively. Which relational algebra operation would be used to retrieve the names
of all students along with their corresponding grades?
a) Projection
b) Outer Join
c) Inner Join
8: Consider a relation named "Employees" with attributes (EmpID, Name, DepartmentID) and another
relation named "Departments" with attributes (DepartmentID, DepartmentName). Which relational
algebra operation would be used to retrieve the names of all employees along with their corresponding
department names?
a) Projection
b) Outer Join
c) Inner Join
9:Consider two relations, "Sales" and "Expenses", with attributes (Date, SaleAmount) and (Date,
ExpenseAmount) respectively. Which relational algebra operation would be used to retrieve the total
profit (SaleAmount - ExpenseAmount) for each date?
a) Projection
b) Selection
c) Difference
a) Projection
b) Outer Join
c) Cross Product