Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
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…
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-…
nother table. This prevents invalid references from being made. Enforcing Referencing Integrity: Use foreign keys to create relationships between tables. Enforce actions like ON DELETE CASCADE, ON UPDATE CASCADE, or ON D…
Referential integrity ensures that relationships between tables are consistent. Specifically, it ensures that a foreign key in one table must match a primary key or a unique key in another table. This prevents invalid re…
composite key is a combination of two or more columns in a table that can uniquely identify each record in the table. It is used when a single column is not sufficient to uniquely identify a row. Composite Key: Consists…
How does it differ from a primary key? A composite key is a combination of two or more columns in a table that can uniquely identify each record in the table. It is used when a single column is not sufficient to uniquely…
n Entity-Relationship Diagram (ERD) is a graphical representation of entities and their relationships to each other within a database. It is used to visualize the structure of a database and how tables (entities) relate…
surrogate key is an artificial, system-generated key used to uniquely identify a record in a table. It has no business meaning and is typically a number (e.g., auto-incremented ID). Surrogate Key: No business meaning. Co…
How is it different from a natural key? A surrogate key is an artificial, system-generated key used to uniquely identify a record in a table. It has no business meaning and is typically a number (e.g., auto-incremented I…
MongoDB is a NoSQL document-oriented database that stores data in flexible, semi-structured documents rather than in rows and columns like SQL databases. Unlike SQL databases, which rely on rigid schemas, MongoDB uses a…
document in MongoDB is a record represented as a JSON-like object (BSON format) that contains field-value pairs. It can have a flexible structure, meaning each document in a collection may contain different fields and da…
How does it differ from rows in SQL databases? A document in MongoDB is a record represented as a JSON-like object (BSON format) that contains field-value pairs. It can have a flexible structure, meaning each document in…
mount of data the system needs to scan. MongoDB creates indexes on fields that are queried frequently. Differences from SQL indexes: MongoDB uses B-tree indexes (by default) but also supports other types like hashed inde…
How is it different from SQL indexes? Indexing in MongoDB is a mechanism to improve query performance by reducing the amount of data the system needs to scan. MongoDB creates indexes on fields that are queried frequently…
The $in operator is used to match values in a specified array. It checks if the value of a field is equal to any value in the provided array. Example: db.collection.find({ age: { $in: [25, 30, 35] } }); This query finds…
utomatically. Sharded Cluster: Used for horizontal scaling. It splits data across multiple servers (shards) based on a shard key. Each shard holds a portion of the data, and a mongos router directs queries to the correct…
Replica Set: A group of MongoDB servers that maintain the same data. It provides high availability and data redundancy by replicating data across multiple servers. If the primary server goes down, one of the secondaries…
find(): Returns a cursor to all documents that match the query. You can iterate over the results using .forEach() or convert them to an array with .toArray(). Example: db.collection.find({ age: { $gt: 30 } }); findOne():…
Answer: nd count occurrences { $sort: { count: -1 } } // Sort by count in descending order ]); What interviewers expect A clear definition tied to SQL in SQL & Databases projects Trade-offs (performance, maintainabil…
How do you use it? The Aggregation Framework in MongoDB is used to perform complex data processing tasks such as grouping, filtering, sorting, and reshaping documents. It uses a pipeline of stages to process documents: E…
ccessed in the database. Since MongoDB is schema-less, data modeling involves deciding how to structure documents, collections, and their relationships (embedded vs. referenced documents) to balance performance, scalabil…
Data modeling in MongoDB refers to the design of how data will be stored, organized, and accessed in the database. Since MongoDB is schema-less, data modeling involves deciding how to structure documents, collections, an…
document schema defines the structure, rules, and validations for documents in a collection. MongoDB is schema-less by default, but you can enforce schema validation rules using MongoDB schema validation. Example: db.cre…
MongoDB Atlas is a fully-managed cloud database service provided by MongoDB Inc. It offers: Automated backups, scaling, and updates. Multi-cloud support (AWS, GCP, Azure). Advanced security features like encryption and I…
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
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).
SQL & Databases SQL Server Tutorial · SQL
nother table. This prevents invalid references from being made.
ON DELETE RESTRICT to define how changes in parent tables affect related
child tables.
Example:
table. If you try to delete a customer that has associated orders, referential integrity
will prevent the delete unless actions like CASCADE are specified.
SQL & Databases SQL Server Tutorial · SQL
Referential integrity ensures that relationships between tables are consistent. Specifically,
it ensures that a foreign key in one table must match a primary key or a unique key in
another table. This prevents invalid references from being made.
ON DELETE RESTRICT to define how changes in parent tables affect related
child tables.
Example:
table. If you try to delete a customer that has associated orders, referential integrity
will prevent the delete unless actions like CASCADE are specified.
SQL & Databases SQL Server Tutorial · SQL
composite key is a combination of two or more columns in a table that can uniquely
identify each record in the table. It is used when a single column is not sufficient to uniquely
identify a row.
Example: A table storing student-course enrollments might use a composite key
consisting of StudentID and CourseID to uniquely identify each enrollment record.
uniquely identifies each record in a table. It can be a single column or a composite
of multiple columns, but it must be unique for each row.
SQL & Databases SQL Server Tutorial · SQL
How does it differ from a primary key?
A composite key is a combination of two or more columns in a table that can uniquely
identify each record in the table. It is used when a single column is not sufficient to uniquely
identify a row.
Example: A table storing student-course enrollments might use a composite key
consisting of StudentID and CourseID to uniquely identify each enrollment record.
uniquely identifies each record in a table. It can be a single column or a composite
of multiple columns, but it must be unique for each row.
SQL & Databases SQL Server Tutorial · SQL
n Entity-Relationship Diagram (ERD) is a graphical representation of entities and their
relationships to each other within a database. It is used to visualize the structure of a
database and how tables (entities) relate to one another.
ERDs help in the conceptual design phase of a database, outlining entities, relationships,
nd keys before implementation.
SQL & Databases SQL Server Tutorial · SQL
surrogate key is an artificial, system-generated key used to uniquely identify a record in a
table. It has no business meaning and is typically a number (e.g., auto-incremented ID).
identify records.
natural keys.
SQL & Databases SQL Server Tutorial · SQL
How is it different from a natural key?
A surrogate key is an artificial, system-generated key used to uniquely identify a record in a
table. It has no business meaning and is typically a number (e.g., auto-incremented ID).
identify records.
natural keys.
SQL & Databases SQL Server Tutorial · SQL
MongoDB is a NoSQL document-oriented database that stores data in flexible,
semi-structured documents rather than in rows and columns like SQL databases. Unlike
SQL databases, which rely on rigid schemas, MongoDB uses a schema-less approach
where each document can have different fields and structures.
Key differences:
transactions for consistency.
flexibility, scalability, and ease of replication but may sacrifice some consistency in
distributed environments.
SQL & Databases SQL Server Tutorial · SQL
document in MongoDB is a record represented as a JSON-like object (BSON format)
that contains field-value pairs. It can have a flexible structure, meaning each document in a
collection may contain different fields and data types.
Differences from SQL Rows:
document is more flexible and can vary in structure.
store complex, nested data structures (arrays, sub-documents).
SQL & Databases SQL Server Tutorial · SQL
How does it differ from rows in
SQL databases?
A document in MongoDB is a record represented as a JSON-like object (BSON format)
that contains field-value pairs. It can have a flexible structure, meaning each document in a
collection may contain different fields and data types.
Differences from SQL Rows:
a document is more flexible and can vary in structure.
store complex, nested data structures (arrays, sub-documents).
SQL & Databases SQL Server Tutorial · SQL
mount of data the system needs to scan. MongoDB creates indexes on fields that are
queried frequently.
Differences from SQL indexes:
hashed indexes, geospatial indexes, and text indexes.
indexes can be dynamic, allowing indexing on any field within a document.
queries.
SQL & Databases SQL Server Tutorial · SQL
How is it different from SQL indexes?
Indexing in MongoDB is a mechanism to improve query performance by reducing the
amount of data the system needs to scan. MongoDB creates indexes on fields that are
queried frequently.
Differences from SQL indexes:
hashed indexes, geospatial indexes, and text indexes.
indexes can be dynamic, allowing indexing on any field within a document.
queries.
SQL & Databases SQL Server Tutorial · SQL
The $in operator is used to match values in a specified array. It checks if the value of a field
is equal to any value in the provided array.
Example:
db.collection.find({ age: { $in: [25, 30, 35] } });
This query finds all documents where the age field is 25, 30, or 35.
SQL & Databases SQL Server Tutorial · SQL
utomatically.
(shards) based on a shard key. Each shard holds a portion of the data, and a
mongos router directs queries to the correct shard. Sharding helps manage large
datasets by distributing the load.
SQL & Databases SQL Server Tutorial · SQL
high availability and data redundancy by replicating data across multiple servers. If
the primary server goes down, one of the secondaries can be promoted to primary
automatically.
(shards) based on a shard key. Each shard holds a portion of the data, and a
mongos router directs queries to the correct shard. Sharding helps manage large
datasets by distributing the load.
SQL & Databases SQL Server Tutorial · SQL
find(): Returns a cursor to all documents that match the query. You can iterate over the
results using .forEach() or convert them to an array with .toArray().
Example:
db.collection.find({ age: { $gt: 30 } });
found.
Example:
db.collection.findOne({ name: "Alice" });
SQL & Databases SQL Server Tutorial · SQL
Answer: nd count occurrences { $sort: { count: -1 } } // Sort by count in descending order ]);
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
How do you use
it?
The Aggregation Framework in MongoDB is used to perform complex data processing
tasks such as grouping, filtering, sorting, and reshaping documents.
It uses a pipeline of stages to process documents:
Example:
db.collection.aggregate([
{ $match: { status: "active" } }, // Filter documents
{ $group: { _id: "$age", count: { $sum: 1 } } }, // Group by age
and count occurrences
{ $sort: { count: -1 } } // Sort by count in descending order
]);
SQL & Databases SQL Server Tutorial · SQL
ccessed in the database. Since MongoDB is schema-less, data modeling involves deciding
how to structure documents, collections, and their relationships (embedded vs. referenced
documents) to balance performance, scalability, and ease of querying.
SQL & Databases SQL Server Tutorial · SQL
Data modeling in MongoDB refers to the design of how data will be stored, organized, and
accessed in the database. Since MongoDB is schema-less, data modeling involves deciding
how to structure documents, collections, and their relationships (embedded vs. referenced
documents) to balance performance, scalability, and ease of querying.
SQL & Databases SQL Server Tutorial · SQL
document schema defines the structure, rules, and validations for documents in a
collection. MongoDB is schema-less by default, but you can enforce schema validation rules
using MongoDB schema validation.
Example:
db.createCollection("users", {
validator: {
$jsonSchema: {
bsonType: "object",
required: ["name", "email"],
properties: {
name: { bsonType: "string" },
email: { bsonType: "string" }
}
}
}
});
SQL & Databases SQL Server Tutorial · SQL
MongoDB Atlas is a fully-managed cloud database service provided by MongoDB Inc. It
offers: