Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
LTER INDEX idx_name ON table_name REORGANIZE; PostgreSQL: PostgreSQL does not have an explicit REORGANIZE command, but you can run VACUUM to clean up the database and reduce fragmentation: VACUUM INDEX idx_name; MySQL: O…
Reorganizing an Index: A lighter operation that compacts the index and defragments it. It is used when fragmentation is low (less than 30%). SQL Server: ALTER INDEX idx_name ON table_name REORGANIZE; PostgreSQL: PostgreS…
Answer: For large datasets, query optimization can be crucial to ensure performance is not impacted. Here are several tips: What interviewers expect A clear definition tied to SQL in SQL & Databases projects Trade-of…
transaction is a sequence of SQL operations that are treated as a single unit of work. A transaction must either be fully completed (committed) or fully undone (rolled back) to ensure the integrity of the database. Trans…
Answer: transaction are invisible to others until the transaction is committed. Durability: Once a transaction is committed, the changes are permanent, even in the case of a system crash. What interviewers expect A clear…
The ACID properties are critical to ensuring the reliability of transactions in a database: Atomicity: All operations within a transaction are executed completely or not at all. Consistency: A transaction takes the datab…
re saved and visible to other transactions. When to use: After the transaction operations have completed successfully and you want to ensure that the changes are saved to the database. Example: BEGIN TRANSACTION; UPDATE…
The COMMIT statement is used to finalize a transaction by making all the changes made during the transaction permanent. It ensures that all changes made during the transaction are saved and visible to other transactions.…
The ROLLBACK statement is used to undo all changes made during a transaction. If an error occurs or something goes wrong, ROLLBACK ensures that the database is restored to its state before the transaction began. When to…
SAVEPOINT is a way to set a point within a transaction to which you can later roll back if necessary. It provides more granular control, allowing partial rollback rather than undoing the entire transaction. When to use:…
The isolation level in SQL defines how transactions interact with each other in terms of visibility of data. The isolation level affects the balance between data consistency and transaction concurrency. READ UNCOMMITTED:…
Can you explain the different isolation levels (e.g., READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE)? The isolation level in SQL defines how transactions interact with each other in terms of visibility…
ffects concurrency in several ways: Locking: Transactions may lock rows or tables to prevent conflicting changes, leading to possible delays for other transactions. Deadlocks: When two or more transactions are waiting fo…
Transactions impact concurrent operations by introducing locking mechanisms to ensure that multiple transactions don't interfere with each other and cause inconsistent data. This affects concurrency in several ways: Lock…
Implicit Transactions: Automatically begin when a database operation is executed. The DBMS treats each individual statement as a transaction and automatically commits after each statement, unless explicitly rolled back.…
Answer: pplication to reattempt the transaction after a short delay. Optimize Transactions: Keep transactions short and ensure that they acquire locks in the same order to reduce the likelihood of deadlocks. What intervi…
Deadlocks occur when two or more transactions are waiting for each other to release locks, causing a cycle of dependencies. To handle deadlocks: Deadlock Detection: DBMS systems (e.g., SQL Server) can automatically detec…
In stored procedures, you control transaction behavior using the following: BEGIN TRANSACTION: Explicitly starts a transaction in the stored procedure. COMMIT: Ends the transaction and commits all changes made during the…
Normalization is the process of organizing a database to reduce redundancy and dependency by dividing large tables into smaller, manageable tables and defining relationships between them. This process aims to improve the…
ddresses a different kind of redundancy or dependency. 1NF (First Normal Form): A table is in 1NF if it contains only atomic (indivisible) values and each record has a unique identifier (Primary Key). No repeating groups…
Normal forms are guidelines used to organize a relational database schema. Each form addresses a different kind of redundancy or dependency. 1NF (First Normal Form): A table is in 1NF if it contains only atomic (indivisi…
Denormalization is the process of intentionally introducing redundancy into a database by merging tables or adding redundant data to reduce the complexity of database queries, improve read performance, and simplify the s…
To normalize a database to 3NF: What interviewers expect A clear definition tied to SQL in SQL & Databases projects Trade-offs (performance, maintainability, security, cost) When you would and would not use it in pro…
Answer: ttributes like CourseName only depend on CourseID would violate 2NF because CourseName is partially dependent on the composite key. You would separate this into two tables (one for Courses and one for Students).…
1NF (First Normal Form): Ensures that the table has atomic columns (no multi-valued or repeating groups) and each row has a unique identifier (Primary Key). 2NF (Second Normal Form): The table must be in 1NF and all non-…
SQL & Databases SQL Server Tutorial · SQL
LTER INDEX idx_name ON table_name REORGANIZE;
PostgreSQL:
PostgreSQL does not have an explicit REORGANIZE command, but you can run VACUUM to
clean up the database and reduce fragmentation:
VACUUM INDEX idx_name;
MySQL:
OPTIMIZE TABLE table_name;
nd recreated. This can reduce fragmentation to nearly zero.
SQL Server:
LTER INDEX idx_name ON table_name REBUILD;
PostgreSQL:
REINDEX INDEX idx_name;
MySQL:
LTER TABLE table_name DROP INDEX idx_name, ADD INDEX idx_name
(column_name);
SQL & Databases SQL Server Tutorial · SQL
Reorganizing an Index: A lighter operation that compacts the index and defragments it. It is
used when fragmentation is low (less than 30%).
SQL Server:
ALTER INDEX idx_name ON table_name REORGANIZE;
PostgreSQL:
PostgreSQL does not have an explicit REORGANIZE command, but you can run VACUUM to
clean up the database and reduce fragmentation:
VACUUM INDEX idx_name;
MySQL:
OPTIMIZE TABLE table_name;
Rebuilding an Index: A more intensive operation where the index is completely dropped
and recreated. This can reduce fragmentation to nearly zero.
SQL Server:
ALTER INDEX idx_name ON table_name REBUILD;
PostgreSQL:
REINDEX INDEX idx_name;
MySQL:
ALTER TABLE table_name DROP INDEX idx_name, ADD INDEX idx_name
(column_name);
SQL & Databases SQL Server Tutorial · SQL
Answer: For large datasets, query optimization can be crucial to ensure performance is not impacted. Here are several tips:
In a production SQL & Databases application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
SQL & Databases SQL Server Tutorial · SQL
transaction is a sequence of SQL operations that are treated as a single unit of work. A
transaction must either be fully completed (committed) or fully undone (rolled back) to
ensure the integrity of the database. Transactions provide the foundation for the ACID
properties (Atomicity, Consistency, Isolation, Durability) that ensure reliable and consistent
operations.
SQL & Databases SQL Server Tutorial · SQL
Answer: transaction are invisible to others until the transaction is committed. Durability: Once a transaction is committed, the changes are permanent, even in the case of a system crash.
In a production SQL & Databases application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
SQL & Databases SQL Server Tutorial · SQL
The ACID properties are critical to ensuring the reliability of transactions in a database:
ensuring that all rules (constraints, triggers, etc.) are respected.
a transaction are invisible to others until the transaction is committed.
case of a system crash.
SQL & Databases SQL Server Tutorial · SQL
re saved and visible to other transactions.
want to ensure that the changes are saved to the database.
Example:
BEGIN TRANSACTION;
UPDATE employees SET salary = 5000 WHERE id = 1;
COMMIT;
SQL & Databases SQL Server Tutorial · SQL
The COMMIT statement is used to finalize a transaction by making all the changes made
during the transaction permanent. It ensures that all changes made during the transaction
are saved and visible to other transactions.
want to ensure that the changes are saved to the database.
Example:
BEGIN TRANSACTION;
UPDATE employees SET salary = 5000 WHERE id = 1;
COMMIT;
SQL & Databases SQL Server Tutorial · SQL
The ROLLBACK statement is used to undo all changes made during a transaction. If an error
occurs or something goes wrong, ROLLBACK ensures that the database is restored to its
state before the transaction began.
made during the transaction.
Example:
BEGIN TRANSACTION;
UPDATE employees SET salary = 5000 WHERE id = 1;
ROLLBACK;
SQL & Databases SQL Server Tutorial · SQL
SAVEPOINT is a way to set a point within a transaction to which you can later roll back if
necessary. It provides more granular control, allowing partial rollback rather than undoing the
entire transaction.
for partial rollback if an error occurs.
Example:
BEGIN TRANSACTION;
SAVEPOINT sp1;
UPDATE employees SET salary = 5000 WHERE id = 1;
ROLLBACK TO sp1; -- Rolls back to the savepoint, undoing only the
changes after it
COMMIT;
SQL & Databases SQL Server Tutorial · SQL
The isolation level in SQL defines how transactions interact with each other in terms of
visibility of data. The isolation level affects the balance between data consistency and
transaction concurrency.
changes made by another transaction. This is the lowest level of isolation.
can change during the transaction).
reads (new rows can appear in a query) are still possible.
reads, and phantom reads by making transactions execute sequentially.
SQL & Databases SQL Server Tutorial · SQL
Can you explain the different isolation
levels (e.g., READ UNCOMMITTED, READ COMMITTED, REPEATABLE
READ, SERIALIZABLE)?
The isolation level in SQL defines how transactions interact with each other in terms of
visibility of data. The isolation level affects the balance between data consistency and
transaction concurrency.
changes made by another transaction. This is the lowest level of isolation.
can change during the transaction).
reads (new rows can appear in a query) are still possible.
reads, and phantom reads by making transactions execute sequentially.
SQL & Databases SQL Server Tutorial · SQL
ffects concurrency in several ways:
leading to possible delays for other transactions.
locks, causing a cycle of dependency. This can be automatically detected and
resolved by the DBMS.
SQL & Databases SQL Server Tutorial · SQL
Transactions impact concurrent operations by introducing locking mechanisms to ensure
that multiple transactions don't interfere with each other and cause inconsistent data. This
affects concurrency in several ways:
leading to possible delays for other transactions.
locks, causing a cycle of dependency. This can be automatically detected and
resolved by the DBMS.
SQL & Databases SQL Server Tutorial · SQL
The DBMS treats each individual statement as a transaction and automatically
commits after each statement, unless explicitly rolled back.
TRANSACTION, COMMIT, and ROLLBACK. The user decides when the transaction
begins and ends.
SQL & Databases SQL Server Tutorial · SQL
Answer: pplication to reattempt the transaction after a short delay. Optimize Transactions: Keep transactions short and ensure that they acquire locks in the same order to reduce the likelihood of deadlocks.
In a production SQL & Databases application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
SQL & Databases SQL Server Tutorial · SQL
Deadlocks occur when two or more transactions are waiting for each other to release locks,
causing a cycle of dependencies. To handle deadlocks:
deadlocks and terminate one of the transactions to break the deadlock.
application to reattempt the transaction after a short delay.
in the same order to reduce the likelihood of deadlocks.
SQL & Databases SQL Server Tutorial · SQL
In stored procedures, you control transaction behavior using the following:
transaction.
wrong.
Example:
BEGIN TRANSACTION;
IF (some_condition)
BEGIN
COMMIT; -- Commit if condition is true
END
ELSE
BEGIN
ROLLBACK; -- Rollback if condition is false
END
Normalization & Database Design
SQL & Databases SQL Server Tutorial · SQL
Normalization is the process of organizing a database to reduce redundancy and
dependency by dividing large tables into smaller, manageable tables and defining
relationships between them. This process aims to improve the structure of the database by
minimizing the chances of data anomalies (insertion, update, and deletion anomalies).
SQL & Databases SQL Server Tutorial · SQL
ddresses a different kind of redundancy or dependency.
has a unique identifier (Primary Key).
functionally dependent on the primary key.
part of a composite primary key).
(non-key attributes depending on other non-key attributes).
removed.
multi-valued attributes.
losing data.
SQL & Databases SQL Server Tutorial · SQL
Normal forms are guidelines used to organize a relational database schema. Each form
addresses a different kind of redundancy or dependency.
has a unique identifier (Primary Key).
functionally dependent on the primary key.
part of a composite primary key).
(non-key attributes depending on other non-key attributes).
removed.
multi-valued attributes.
losing data.
SQL & Databases SQL Server Tutorial · SQL
Denormalization is the process of intentionally introducing redundancy into a database by
merging tables or adding redundant data to reduce the complexity of database queries,
improve read performance, and simplify the schema.
normalization (e.g., in OLAP systems or reporting).
stored redundantly to reduce query times.
SQL & Databases SQL Server Tutorial · SQL
To normalize a database to 3NF:
In a production SQL & Databases application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
SQL & Databases SQL Server Tutorial · SQL
Answer: ttributes like CourseName only depend on CourseID would violate 2NF because CourseName is partially dependent on the composite key. You would separate this into two tables (one for Courses and one for Students).
In a production SQL & Databases application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
SQL & Databases SQL Server Tutorial · SQL
multi-valued or repeating groups) and each row has a unique identifier (Primary Key).
must depend on the entire primary key (i.e., there should be no partial
dependencies).
Example:
attributes like CourseName only depend on CourseID would violate 2NF because
CourseName is partially dependent on the composite key. You would separate this
into two tables (one for Courses and one for Students).