### DBMS Interview Questions by Company
#### Google
1. **What is a transaction, and what are its properties?**
- **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).
2. **Explain the concept of normalization and its benefits.**
- **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.
3. **What are indexes, and how do they work?**
- **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:**
- **INNER JOIN:** Returns rows when there is a match in both tables.
- **OUTER JOIN:** Returns all rows from one table and the matched rows from the other (LEFT,
RIGHT, FULL).
5. **What is sharding in databases?**
- **Answer:** Sharding is a method of distributing data across multiple databases to improve
scalability and performance.
#### Microsoft
6. **What is a foreign key, and why is it important?**
- **Answer:** A foreign key is a column or a set of columns that establishes a link between data in two
tables. It is important for maintaining referential integrity.
7. **Explain the difference between DELETE, TRUNCATE, and DROP commands.**
- **Answer:**
- **DELETE:** Removes rows from a table based on a condition; can be rolled back.
- **TRUNCATE:** Removes all rows from a table; cannot be rolled back.
- **DROP:** Removes the entire table or database.
8. **What is a stored procedure, and how is it different from a function?**
- **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.
9. **What is the purpose of a database trigger?**
- **Answer:** A trigger is a set of actions automatically executed in response to certain events on a
table, such as INSERT, UPDATE, or DELETE operations.
10. **What is the difference between a clustered and a non-clustered index?**
- **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
11. **What are ACID properties in DBMS?**
- **Answer:** ACID stands for Atomicity, Consistency, Isolation, and Durability, which are the
properties that ensure reliable processing of database transactions.
12. **What is database partitioning?**
- **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.
14. **What is a schema in a database?**
- **Answer:** A schema is a logical structure that defines the organization of data in a database,
including tables, views, indexes, and relationships.
15. **How do you handle database deadlocks?**
- **Answer:** Deadlocks can be handled by using techniques like timeout, deadlock detection and
recovery, or avoiding cyclic wait conditions.
#### Facebook
16. **What is a database index, and why is it used?**
- **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.
17. **What is referential integrity in DBMS?**
- **Answer:** Referential integrity ensures that a foreign key value always points to an existing, valid
primary key in another table, maintaining data consistency.
18. **What are the advantages of using stored procedures?**
- **Answer:** Stored procedures improve performance, enhance security, and promote code
reusability by encapsulating complex logic in the database.
19. **What is the difference between UNION and UNION ALL?**
- **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
21. **Explain the concept of a view in SQL.**
- **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.
22. **What is database normalization, and what are its types?**
- **Answer:** Normalization is the process of organizing data to reduce redundancy. Types include
1NF, 2NF, 3NF, BCNF, 4NF, and 5NF.
23. **What is a cursor, and why is it used in SQL?**
- **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.
24. **What is the difference between a sequence and an auto-increment field?**
- **Answer:**
- **Sequence:** A database object that generates a sequence of numbers according to specified
rules.
- **Auto-increment:** A column attribute that automatically generates the next number in a
sequence for new records.
25. **What is a data warehouse?**
- **Answer:** A data warehouse is a centralized repository that stores integrated data from multiple
sources, optimized for analysis and reporting.
#### IBM
26. **What is a database trigger, and how does it work?**
- **Answer:** A trigger is a set of SQL statements that automatically execute when a specified event
occurs on a table, such as INSERT, UPDATE, or DELETE.
27. **What is a relational database?**
- **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.
28. **What is the role of a database administrator (DBA)?**
- **Answer:** A DBA is responsible for installing, configuring, and maintaining the database system,
ensuring its availability, performance, and security.
29. **What is the purpose of a primary key in a table?**
- **Answer:** A primary key uniquely identifies each record in a table, ensuring data integrity and
enabling efficient data retrieval.
30. **What are aggregate functions in SQL?**
- **Answer:** Aggregate functions perform calculations on a set of values and return a single value,
such as SUM, COUNT, AVG, MIN, and MAX.
#### Salesforce
31. **What is data integrity, and why is it important?**
- **Answer:** Data integrity ensures the accuracy and consistency of data over its lifecycle, which is
critical for reliable database operations.
32. **What is the difference between OLTP and OLAP?**
- **Answer:**
- **OLTP:** Focuses on transaction-oriented applications with frequent reads and writes.
- **OLAP:** Focuses on analytical processing with complex queries and data analysis.
33. **What is a correlated subquery?**
- **Answer:** A correlated subquery is a subquery that references columns from the outer query,
executing once for each row processed by the outer query.
34. **What is referential transparency in DBMS?**
- **Answer:** Referential transparency ensures that any reference to a data item is consistent and
always points to the correct value, ensuring query reliability.
35. **What is a candidate key?**
- **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
36. **What is SQL injection, and how can it be prevented?**
- **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.
37. **What is a full-text search in SQL?**
- **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.
38. **What are database constraints?**
- **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.
39. **Explain the difference between a schema and a table.**
- **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.
40. **What is a surrogate key in a database?**
- **Answer:** A surrogate key is an artificial key used to uniquely identify a record in a table, typically
generated automatically by the database system.
#### Uber
41. **What is a database cluster?**
- **Answer:** A database cluster is a group of databases managed by a single DBMS that provides
high availability and scalability by
distributing data across multiple servers.
42. **What is a materialized view?**
- **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.
44. **What is the difference between a view and a table in SQL?**
- **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.
45. **What is the purpose of a JOIN clause in SQL?**
- **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:** An Entity-Relationship (ER) diagram is a graphical representation of the entities,
attributes, and relationships in a database, used for designing database schemas.
47. **What is the purpose of the HAVING clause in SQL?**
- **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:**
- **Scalar functions:** Operate on individual values (e.g., UPPER, LOWER).
- **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**
1. **What is data integrity, and why is it important in DBMS?**
- **Answer:** Data integrity ensures the accuracy and consistency of data within the database, which
is crucial for reliable information and operations.
2. **What is a composite key?**
- **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.
4. **What is a surrogate key?**
- **Answer:** A surrogate key is a unique identifier for an entity, typically a sequential number that is
not derived from the business data.
5. **What is the difference between WHERE and HAVING clauses?**
- **Answer:** WHERE filters rows before grouping, while HAVING filters groups after the GROUP BY
operation.
#### **Tesla**
6. **What is a self-join, and when would you use it?**
- **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.
7. **Explain what a checkpoint is in DBMS.**
- **Answer:** A checkpoint is a mechanism to reduce the amount of work needed during database
recovery by periodically saving the current state to disk.
8. **What is the difference between OLTP and OLAP?**
- **Answer:**
- **OLTP (Online Transaction Processing):** Handles daily transactions.
- **OLAP (Online Analytical Processing):** Supports complex queries for data analysis.
9. **What is a cross join in SQL?**
- **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**
11. **What are the different types of database relationships?**
- **Answer:** The types include one-to-one, one-to-many, and many-to-many relationships.
12. **Explain what data denormalization is.**
- **Answer:** Denormalization involves combining tables to improve read performance at the cost of
redundancy and write performance.
13. **What is a non-clustered index?**
- **Answer:** A non-clustered index creates a separate structure from the data rows, which includes a
pointer back to the data.
14. **What is the use of the COALESCE function in SQL?**
- **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**
16. **Explain the concept of a subquery.**
- **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.
19. **What are constraints in DBMS?**
- **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**
21. **What is a database trigger, and how does it work?**
- **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.
22. **What is the purpose of a JOIN clause in SQL?**
- **Answer:** JOIN clauses combine rows from two or more tables based on a related column,
allowing complex queries across multiple tables.
23. **What is a functional dependency in DBMS?**
- **Answer:** A functional dependency is a relationship where one attribute uniquely determines
another attribute in a table.
24. **Explain the concept of a view in SQL.**
- **Answer:** A view is a virtual table based on the result set of a SELECT query; it provides a way to
simplify complex queries.
25. **What is a materialized view?**
- **Answer:** A materialized view stores the result of a query physically and can be refreshed
periodically to reflect changes in the underlying data.
#### **Snapchat**
26. **What are the benefits of using stored procedures?**
- **Answer:** Stored procedures enhance performance, provide security, reduce network traffic, and
promote code reusability.
27. **Explain the difference between UNION and JOIN operations.**
- **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.
28. **What is a bitmap index?**
- **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.
30. **What is the role of a data dictionary in DBMS?**
- **Answer:** A data dictionary stores metadata about the database structure, such as table
definitions, data types, and relationships.
#### **Airbnb**
31. **What is the purpose of the DISTINCT keyword in SQL?**
- **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.
33. **Explain what a database checkpoint is.**
- **Answer:** A checkpoint is a point of synchronization between the database and the transaction
log, used to minimize recovery time.
34. **What is a correlated subquery?**
- **Answer:** A correlated subquery references columns from the outer query, executing once for
each row processed by the outer query.
35. **What is a snowflake schema in data warehousing?**
- **Answer:** A snowflake schema is a logical arrangement of tables in a multidimensional database
that resembles a snowflake shape, with normalized dimensions.
#### **Dropbox**
36. **What is a database snapshot?**
- **Answer:** A snapshot is a read-only, static view of a database at a particular point in time, used
for backup and reporting.
37. **What is a fact table in a data warehouse?**
- **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.
39. **What is the purpose of normalization?**
- **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**
41. **What is referential integrity, and how is it enforced in SQL?**
- **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.
43. **Explain the difference between OLTP and OLAP.**
- **Answer:** OLTP is used for day-to-day transaction processing, while OLAP is used for data analysis
and decision support.
44. **What is the difference between a schema and an instance?**
- **Answer:**
- **Schema:** The structure or design of the database.
- **Instance:** The actual data stored in the database at a particular moment.
45. **What is a star schema in data warehousing?**
- **Answer:** A star schema is a type of database schema