Database Management System: Questions and Answers
1. Identify the candidate key(s) for the given relation:
For R(A, B, C, D) with functional dependencies A → B and C → D:
Candidate keys are attributes or combinations of attributes that uniquely identify every
tuple in a relation.
Since A determines B and C determines D, A and C together form a candidate key: AC.
2. Discuss Checkpoint in DBMS. Why is it important in transaction management?
Checkpoint: A point in time when all data and transaction logs are saved to disk, ensuring
that the database can recover from failures.
Importance:
- Reduces recovery time after a crash.
- Ensures a consistent state of the database.
- Saves the cost of reprocessing completed transactions.
3. Define Referential Integrity with an example.
Referential Integrity ensures that relationships between tables remain consistent.
Example: In a database with tables Orders and Customers, if Orders has a CustomerID
foreign key referencing Customers, referential integrity ensures that each CustomerID in
Orders exists in Customers.
4. Write the difference between DDL and DML.
DML (Data Manipulation
Aspect DDL (Data Definition Language)
Language)
Defines database schema and Manipulates data in existing
Purpose
structure. structures.
SELECT, INSERT, UPDATE,
Commands CREATE, ALTER, DROP.
DELETE.
May require explicit
Execution Auto-committed.
commit/rollback.
5. Differentiate between lossless join and dependency preservation.
- Lossless Join: Ensures that when a relation is decomposed, joining the decomposed
relations restores the original relation without loss of data.
- Dependency Preservation: Ensures that all functional dependencies are preserved in the
decomposed relations without the need for recomputation.
6. Define DBMS and RDBMS.
- DBMS (Database Management System): A software system for storing and managing
data. Example: Microsoft Access.
- RDBMS (Relational DBMS): A DBMS that uses relations (tables) to store data with
constraints like primary and foreign keys. Example: MySQL, PostgreSQL.
7. Explain normalization and its importance.
- Normalization: A process of organizing data to minimize redundancy and dependency.
Importance:
- Reduces data anomalies.
- Enhances data integrity.
- Improves query performance.
8. What is SQL?
SQL (Structured Query Language): A standard language for managing and manipulating
relational databases.
Used for querying, updating, and defining database schema.
9. Differentiate between DELETE, DROP, and TRUNCATE.
Aspect DELETE DROP TRUNCATE
Deletes specific rows from Deletes entire Deletes all rows in a
Purpose
a table. database/table. table.
Cannot be rolled
Undo Can be rolled back. Cannot be rolled back.
back.
Retains table
Structure Retains table structure. Deletes structure too.
structure.
10. What is Primary and Foreign Key?
- Primary Key: A unique identifier for table rows, ensuring no duplicates.
- Foreign Key: A field in one table referencing the primary key in another table to
maintain referential integrity.
11. What is a trigger in DBMS?
Trigger: A procedural code executed automatically in response to specific events
(INSERT, UPDATE, DELETE) on a table.
12. What is a view in SQL?
View: A virtual table created using a SQL query, which does not store data but provides a
result set dynamically.
13. What is the difference between UNION and UNION ALL?
Aspect UNION UNION ALL
Duplicates Removes duplicate rows. Includes duplicate rows.
Performance Slower due to duplicate removal. Faster as no duplicate removal.
14. Differentiate between INNER JOIN and OUTER JOIN.
Aspect INNER JOIN OUTER JOIN
Matches Returns matching rows only. Includes non-matching rows too.
Types N/A LEFT, RIGHT, FULL OUTER JOIN.
15. What is the difference between CROSS JOIN and SELF JOIN?
Aspect CROSS JOIN SELF JOIN
Produces Cartesian product of
Purpose Joins a table to itself.
rows.
Finding relationships within the same
Use Case Combining unrelated rows.
table.