DBMS Interview Questions by Company
DBMS Interview Questions by Company
- **Answer:** A transaction is a sequence of operations performed as a single logical unit of work. Its
properties are Atomicity, Consistency, Isolation, and Durability (ACID).
- **Answer:** Normalization is the process of organizing data to reduce redundancy and improve data
integrity. Benefits include minimized data duplication, improved data integrity, and easier maintenance.
- **Answer:** Indexes are data structures that improve the speed of data retrieval operations on a
database table by providing a fast way to access rows. They work by creating an internal structure that
references the data in the table.
4. **What are the differences between INNER JOIN and OUTER JOIN?**
- **Answer:**
- **OUTER JOIN:** Returns all rows from one table and the matched rows from the other (LEFT,
RIGHT, FULL).
#### Microsoft
- **Answer:**
- **DELETE:** Removes rows from a table based on a condition; can be rolled back.
- **Answer:** A stored procedure is a set of SQL statements that can be executed as a single unit.
Unlike functions, procedures do not have to return a value.
- **Answer:** A clustered index sorts and stores the data rows in the table based on the index key,
whereas a non-clustered index maintains a separate structure from the data rows.
#### Amazon
- **Answer:** ACID stands for Atomicity, Consistency, Isolation, and Durability, which are the
properties that ensure reliable processing of database transactions.
- **Answer:** Partitioning divides a large database table into smaller, more manageable pieces
without changing the logical structure of the table.
13. **Explain the use of the GROUP BY clause in SQL.**
- **Answer:** The GROUP BY clause groups rows that have the same values in specified columns into
aggregate data, such as counts or sums.
- **Answer:** A schema is a logical structure that defines the organization of data in a database,
including tables, views, indexes, and relationships.
- **Answer:** Deadlocks can be handled by using techniques like timeout, deadlock detection and
recovery, or avoiding cyclic wait conditions.
- **Answer:** A database index is a data structure that improves the speed of data retrieval
operations on a table at the cost of additional storage and slower write operations.
- **Answer:** Referential integrity ensures that a foreign key value always points to an existing, valid
primary key in another table, maintaining data consistency.
- **Answer:** Stored procedures improve performance, enhance security, and promote code
reusability by encapsulating complex logic in the database.
- **Answer:** UNION removes duplicate records from the combined result set, while UNION ALL
includes all duplicates.
20. **What is the difference between a primary key and a unique key?**
- **Answer:** Both enforce uniqueness, but a primary key does not allow NULL values, while a unique
key can have a single NULL value.
#### Oracle
- **Answer:** A view is a virtual table based on the result set of a SELECT query. It does not store data
physically and provides a way to simplify complex queries.
- **Answer:** Normalization is the process of organizing data to reduce redundancy. Types include
1NF, 2NF, 3NF, BCNF, 4NF, and 5NF.
- **Answer:** A cursor is a database object used to retrieve, manipulate, and navigate through the
result set of a query one row at a time.
- **Answer:**
- **Answer:** A data warehouse is a centralized repository that stores integrated data from multiple
sources, optimized for analysis and reporting.
#### IBM
- **Answer:** A relational database is a type of database that stores data in tables with rows and
columns, using relations (keys) to connect related data.
- **Answer:** A DBA is responsible for installing, configuring, and maintaining the database system,
ensuring its availability, performance, and security.
- **Answer:** A primary key uniquely identifies each record in a table, ensuring data integrity and
enabling efficient data retrieval.
- **Answer:** Aggregate functions perform calculations on a set of values and return a single value,
such as SUM, COUNT, AVG, MIN, and MAX.
#### Salesforce
- **Answer:** Data integrity ensures the accuracy and consistency of data over its lifecycle, which is
critical for reliable database operations.
- **Answer:**
- **OLAP:** Focuses on analytical processing with complex queries and data analysis.
- **Answer:** Referential transparency ensures that any reference to a data item is consistent and
always points to the correct value, ensuring query reliability.
- **Answer:** A candidate key is a minimal set of attributes that can uniquely identify a record in a
table. There can be multiple candidate keys, but only one is chosen as the primary key.
#### Cisco
- **Answer:** SQL injection is a security vulnerability that allows attackers to manipulate SQL queries.
It can be prevented by using parameterized queries, input validation, and stored procedures.
- **Answer:** Full-text search allows searching for textual data in a database by matching words or
phrases. It is more efficient than using LIKE operators for large text fields.
- **Answer:** Constraints are rules applied to columns in a database table to enforce data integrity.
Common constraints include PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, and CHECK.
- **Answer:**
- **Schema:** A logical container for database objects like tables, views, and indexes.
- **Table:** A database object that stores data in rows and columns within a schema.
#### Uber
- **Answer:** A database cluster is a group of databases managed by a single DBMS that provides
high availability and scalability by
- **Answer:** A materialized view is a view that stores the result of a query physically and can be
refreshed periodically to reflect changes in the underlying data.
43. **What are ACID transactions, and why are they important?**
- **Answer:** ACID transactions ensure reliable and consistent database transactions, which are
crucial for data integrity and reliability in a multi-user environment.
- **Answer:**
- **View:** A virtual table based on a query; does not store data physically.
- **Table:** A database object that stores data physically in rows and columns.
- **Answer:** The JOIN clause combines rows from two or more tables based on a related column,
allowing for complex data retrieval across multiple tables.
#### Adobe
46. **What is an ER diagram?**
- **Answer:** The HAVING clause filters groups of rows that meet certain conditions, often used with
GROUP BY to filter aggregate data.
48. **What is the difference between scalar and aggregate functions in SQL?**
- **Answer:**
- **Aggregate functions:** Operate on a set of values and return a single value (e.g., SUM, COUNT).
49. **What is an index in a database, and when would you use one?**
- **Answer:** An index is used to improve the speed of data retrieval operations by providing quick
access to rows. It is used when frequent searches or sorts are performed on a column.
50. **What are triggers in SQL, and when are they useful?**
- **Answer:** Triggers are automatic actions executed in response to specific events on a table. They
are useful for enforcing business rules, maintaining audit trails, or synchronizing tables.
#### **Apple**
- **Answer:** Data integrity ensures the accuracy and consistency of data within the database, which
is crucial for reliable information and operations.
- **Answer:** A composite key is a primary key made up of two or more columns used to uniquely
identify a record.
3. **Explain the use of the HAVING clause in SQL.**
- **Answer:** The HAVING clause is used to filter groups of rows that meet a certain condition, often
used with GROUP BY.
- **Answer:** A surrogate key is a unique identifier for an entity, typically a sequential number that is
not derived from the business data.
- **Answer:** WHERE filters rows before grouping, while HAVING filters groups after the GROUP BY
operation.
#### **Tesla**
- **Answer:** A self-join is a join of a table with itself. It is used when you need to compare rows
within the same table.
- **Answer:** A checkpoint is a mechanism to reduce the amount of work needed during database
recovery by periodically saving the current state to disk.
- **Answer:**
- **OLAP (Online Analytical Processing):** Supports complex queries for data analysis.
- **Answer:** A cross join returns the Cartesian product of the two tables, combining each row from
the first table with every row from the second table.
10. **What are sequences in SQL?**
- **Answer:** Sequences generate a series of unique numbers, often used for creating primary key
values.
#### **Netflix**
- **Answer:** Denormalization involves combining tables to improve read performance at the cost of
redundancy and write performance.
- **Answer:** A non-clustered index creates a separate structure from the data rows, which includes a
pointer back to the data.
- **Answer:** COALESCE returns the first non-null value from a list of arguments.
15. **What is the difference between scalar functions and aggregate functions in SQL?**
- **Answer:**
- **Scalar functions:** Operate on a single value and return a single value (e.g., UPPER, LOWER).
- **Aggregate functions:** Operate on a set of values and return a single value (e.g., SUM, AVG).
#### **Intel**
- **Answer:** A subquery is a query nested inside another query, used to perform operations like
filtering, calculation, or selection within the main query.
17. **What are transaction logs, and why are they important?**
- **Answer:** Transaction logs record all changes made to the database, which are crucial for data
recovery and rollback operations.
18. **What is an index in a database, and when would you use one?**
- **Answer:** Indexes speed up data retrieval operations by providing a quick access path to rows in a
table, used when queries frequently search on specific columns.
- **Answer:** Constraints enforce rules on data in the database, such as PRIMARY KEY, FOREIGN KEY,
UNIQUE, CHECK, and NOT NULL.
20. **What is the difference between a primary key and a candidate key?**
- **Answer:**
- **Primary Key:** A unique identifier for table rows that cannot be null.
- **Candidate Key:** A set of columns that could potentially be chosen as the primary key.
#### **Twitter**
- **Answer:** A trigger is a set of SQL statements that automatically execute in response to certain
events on a table, like INSERT, UPDATE, or DELETE.
- **Answer:** JOIN clauses combine rows from two or more tables based on a related column,
allowing complex queries across multiple tables.
- **Answer:** A view is a virtual table based on the result set of a SELECT query; it provides a way to
simplify complex queries.
- **Answer:** A materialized view stores the result of a query physically and can be refreshed
periodically to reflect changes in the underlying data.
#### **Snapchat**
- **Answer:** Stored procedures enhance performance, provide security, reduce network traffic, and
promote code reusability.
- **Answer:**
- **UNION:** Combines results from multiple SELECT statements into a single result set.
- **JOIN:** Combines rows from two or more tables based on related columns.
- **Answer:** A bitmap index uses bitmaps and bitwise operations to quickly locate rows in large,
low-cardinality datasets.
29. **What is a database cursor, and when would you use it?**
- **Answer:** A cursor is used to iterate over the results of a query one row at a time, often used for
row-by-row processing.
- **Answer:** A data dictionary stores metadata about the database structure, such as table
definitions, data types, and relationships.
#### **Airbnb**
- **Answer:** DISTINCT removes duplicate records from the result set of a SELECT query.
32. **What is a clustered index, and how is it different from a non-clustered index?**
- **Answer:** A clustered index sorts and stores the data rows based on the index key, while a non-
clustered index maintains a separate structure from the data rows.
- **Answer:** A checkpoint is a point of synchronization between the database and the transaction
log, used to minimize recovery time.
- **Answer:** A correlated subquery references columns from the outer query, executing once for
each row processed by the outer query.
#### **Dropbox**
- **Answer:** A snapshot is a read-only, static view of a database at a particular point in time, used
for backup and reporting.
- **Answer:** A fact table stores quantitative data for analysis and is linked to dimension tables.
38. **Explain the difference between logical and physical data independence.**
- **Answer:**
- **Logical Data Independence:** The capacity to change the conceptual schema without altering
external schemas or application programs.
- **Physical Data Independence:** The ability to change the internal schema without changing the
conceptual schema.
- **Answer:** Normalization organizes data to reduce redundancy and improve data integrity.
40. **What is a surrogate key, and when would you use one?**
- **Answer:** A surrogate key is a unique identifier that is not derived from business data, often used
as a primary key when no natural key is available.
#### **LinkedIn**
- **Answer:** Referential integrity ensures that foreign keys correctly and consistently reference
primary keys. It is enforced through constraints.
42. **What is a data warehouse, and how does it differ from a database?**
- **Answer:** A data warehouse is optimized for data analysis and reporting, storing large volumes of
historical data, whereas a database is typically used for transaction processing.
- **Answer:** OLTP is used for day-to-day transaction processing, while OLAP is used for data analysis
and decision support.
- **Answer:**
- **Schema:** The structure or design of the database.