Explore the fundamentals of DBMS with our collection of essential beginner-level questions.
Deepen your DBMS knowledge with our advanced questions that cover state management and cross-platform compatibility.
Master DBMS with our expert-level questions that delve into performance optimization and the inner workings of the DBMS bridge.
Answer: A DBMS is a software system that allows users to create, manage, and manipulate databases. It provides an interface to define, retrieve, update, and manage data in a structured manner. Key components include: - Data Definition Language (DDL) - Data Manipulation Language (DML) - Data Query Language (DQL) - Data Storage and Retrieval mechanisms
Answer: A database is an organized collection of data stored electronically, while a DBMS is the software used to manage that data. The database is the structure and content, and the DBMS is the tool that interacts with the data. Key differences: - A database contains data; DBMS provides the tools to manage that data. - DBMS controls access, updates, and query handling for the database.
Answer: The main types of databases are: - Relational Databases: Structured data stored in tables with rows and columns (e.g., MySQL, PostgreSQL). - NoSQL Databases: Non-relational, flexible schema for unstructured or semi-structured data (e.g., MongoDB, Cassandra). - In-memory Databases: Data stored in main memory for high-speed access (e.g., Redis, Memcached). - Object-Oriented Databases: Stores data as objects rather than tables (e.g., db4o, ObjectDB).
Answer: A primary key is a unique identifier for each record in a table. It ensures that no two records have the same primary key value. Primary keys help maintain data integrity. Example: - Table: Students - Columns: StudentID (Primary Key)
Answer: Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity. It involves dividing large tables into smaller tables and defining relationships between them. Normalization is used to: - Eliminate redundancy. - Ensure data consistency. - Minimize update anomalies.
Answer: The main types of normalization are: - First Normal Form (1NF): Ensures atomicity and uniqueness of data. - Second Normal Form (2NF): Ensures 1NF and removes partial dependencies. - Third Normal Form (3NF): Ensures 2NF and removes transitive dependencies. - Boyce-Codd Normal Form (BCNF): Ensures no redundancy and is a stricter form of 3NF.
Answer: A foreign key is a column in one table that refers to the primary key of another table. It establishes a link between tables, ensuring referential integrity. Example: - Table: Orders - Columns: OrderID (Primary Key), CustomerID (Foreign Key referring to Customers table)
Answer: A transaction is a sequence of operations performed as a single logical unit of work. Transactions ensure consistency and isolation of data. Key properties: - Atomicity: All or none of the operations are completed. - Consistency: Data remains in a consistent state. - Isolation: Transactions are isolated from each other. - Durability: Completed transactions are permanent.
Answer: ACID stands for: - Atomicity: All operations in a transaction are completed successfully or none are. - Consistency: The database remains in a consistent state before and after the transaction. - Isolation: Transactions are isolated from each other. - Durability: Once a transaction is committed, its changes are permanent.
Answer: Database locks are mechanisms used to ensure data consistency in concurrent transactions. Types of locks: - Shared Lock: Allows multiple transactions to read the data but prevents updates. - Exclusive Lock: Allows a transaction to update data but prevents others from accessing it. - Read Lock: Allows read-only access and prevents writes. - Write Lock: Allows write access and prevents other operations.
Answer: A join operation combines rows from two or more tables based on related columns. Types of joins: - INNER JOIN: Returns rows with matching values from both tables. - LEFT JOIN: Returns all rows from the left table and matching rows from the right table. - RIGHT JOIN: Returns all rows from the right table and matching rows from the left table. - FULL OUTER JOIN: Returns all matching and non-matching rows from both tables.
Answer: UNION combines the results of two or more SELECT queries and removes duplicate rows. UNION ALL combines the results and keeps all rows, including duplicates.
Answer: A view is a virtual table that is based on the result set of a SELECT query. It does not store the data but provides a way to present specific columns and rows. Example: - CREATE VIEW customer_orders AS SELECT customer_id, order_id FROM orders;
Answer: A stored procedure is a precompiled set of SQL statements that can be executed repeatedly. It performs operations like inserting, updating, or retrieving data. Example: - CREATE PROCEDURE GetCustomerOrders (IN customerID INT) - BEGIN - SELECT * FROM orders WHERE customer_id = customerID; - END;
Answer: A trigger is a set of SQL statements that are automatically executed in response to specific events (INSERT, UPDATE, DELETE) on a table. Types: - BEFORE Trigger: Executes before an event occurs. - AFTER Trigger: Executes after an event occurs. - INSTEAD OF Trigger: Replaces the event with its logic.
Answer: Denormalization is the process of introducing redundancy into a database to improve read performance. It is used to: - Simplify query execution. - Reduce the complexity of joins. - Speed up read-intensive operations.
Answer: A database schema defines the structure of a database, including tables, columns, data types, relationships, and constraints. Example: - CREATE TABLE Students (StudentID INT PRIMARY KEY, Name VARCHAR(100), Age INT);
Answer: Indexing improves the performance of data retrieval operations by reducing the amount of data that needs to be read from the database. Types of indexes: - Clustered Index: Arranges data rows in a sorted order. - Non-clustered Index: Points to the data rows and is stored separately.
Answer: A cursor is a database object used to retrieve, manipulate, and navigate through the result set row by row. Syntax: - DECLARE cursor_name CURSOR FOR SELECT column_name FROM table_name;
Answer: A foreign key constraint ensures that the value in a column matches the primary key in another table, maintaining referential integrity. Example: - ALTER TABLE Orders ADD CONSTRAINT fk_customer FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID);