Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Executing stored procedures asynchronously can improve the performance of applications by allowing other tasks to run while waiting for the procedure to finish. Example (C#): using (SqlConnection conn = new SqlConnection…
Vendor Lock-In: Stored procedures use database-specific syntax, making it harder to migrate to different database platforms. Complexity: As business logic grows within stored procedures, they can become difficult to main…
Answer: Debugging stored procedures can be done in the following ways: SQL Server: SQL Server Management Studio (SSMS) allows you to set breakpoints, step through the code, and inspect variable values during execution. S…
Indexes improve query performance in several ways: What interviewers expect A clear definition tied to SQL in SQL & Databases projects Trade-offs (performance, maintainability, security, cost) When you would and woul…
There are several types of indexes in SQL: Unique Index: Ensures that all values in the indexed column(s) are unique. Automatically created when a PRIMARY KEY or UNIQUE constraint is defined on a column. Example: CREATE…
Answer: Creating an Index: CREATE INDEX idx_index_name ON table_name(column_name); Dropping an Index: DROP INDEX idx_index_name ON table_name; In SQL Server, dropping an index: DROP INDEX idx_index_name; -- No need to sp…
Consider creating an index when: 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 pr…
Answer: The query optimizer in the database engine decides which index to use based on several factors: What interviewers expect A clear definition tied to SQL in SQL & Databases projects Trade-offs (performance, mai…
Answer: Index fragmentation occurs when data is inserted, updated, or deleted, causing the index structure to become inefficient. This can negatively impact performance in several ways: What interviewers expect A clear d…
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…
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…
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…
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…
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…
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: Data redundancy occurs when the same piece of data is stored in multiple places, which can lead to inconsistencies and wasted storage. To avoid redundancy: What interviewers expect A clear definition tied to SQL…
Answer: pplication? Designing a database schema for a large e-commerce application involves careful consideration of data requirements, scalability, and normalization. Key entities and relationships to consider: What int…
Answer: Designing a database schema for a large e-commerce application involves careful consideration of data requirements, scalability, and normalization. Key entities and relationships to consider: What interviewers ex…
SQL & Databases SQL Server Tutorial · SQL
Executing stored procedures asynchronously can improve the performance of applications
by allowing other tasks to run while waiting for the procedure to finish.
Example (C#):
using (SqlConnection conn = new SqlConnection(connectionString))
await conn.OpenAsync();
using (SqlCommand cmd = new SqlCommand("GetEmployeeDetails",
conn))
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@emp_id",
SqlDbType.Int)).Value = 101;
using (SqlDataReader reader = await
cmd.ExecuteReaderAsync())
while (await reader.ReadAsync())
Console.WriteLine(reader["name"]);
SQL & Databases SQL Server Tutorial · SQL
to migrate to different database platforms.
difficult to maintain and debug.
hurt performance.
code, and they cannot easily handle more complex logic that might be easier in a
high-level programming language.
application code.
SQL & Databases SQL Server Tutorial · SQL
Answer: Debugging stored procedures can be done in the following ways: SQL Server: SQL Server Management Studio (SSMS) allows you to set breakpoints, step through the code, and inspect variable values during execution. Steps:
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
Indexes improve query performance in several ways:
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
There are several types of indexes in SQL:
Unique Index: Ensures that all values in the indexed column(s) are unique. Automatically
created when a PRIMARY KEY or UNIQUE constraint is defined on a column.
Example:
CREATE UNIQUE INDEX idx_employee_id ON employees(id);
like full-text searches (e.g., MATCH in MySQL).
Example (MySQL):
CREATE FULLTEXT INDEX idx_fulltext_desc ON products(description);
index. Each table can have only one clustered index.
indexed columns and pointers to the actual data rows. A table can have multiple
non-clustered indexes.
filter based on multiple columns.
polygons (mostly for geographical data).
SQL & Databases SQL Server Tutorial · SQL
Answer: Creating an Index: CREATE INDEX idx_index_name ON table_name(column_name); Dropping an Index: DROP INDEX idx_index_name ON table_name; In SQL Server, dropping an index: DROP INDEX idx_index_name; -- No need to specify table name.
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
Consider creating an index when:
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: The query optimizer in the database engine decides which index to use based on several factors:
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: Index fragmentation occurs when data is inserted, updated, or deleted, causing the index structure to become inefficient. This can negatively impact performance in several ways:
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
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
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
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
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
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
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: Data redundancy occurs when the same piece of data is stored in multiple places, which can lead to inconsistencies and wasted storage. To avoid redundancy:
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: pplication? Designing a database schema for a large e-commerce application involves careful consideration of data requirements, scalability, and normalization. Key entities and relationships to consider:
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: Designing a database schema for a large e-commerce application involves careful consideration of data requirements, scalability, and normalization. Key entities and relationships to consider:
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.