4. Advanced Database Questions Flashcards

1
Q

What is the difference between a relational database and a NoSQL database?

A

Relational databases use structured schemas and SQL for data manipulation, while NoSQL databases are more flexible, allowing for unstructured data and various data models.

Examples of NoSQL databases include MongoDB and Cassandra.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you implement horizontal scaling in a relational database?

A

Horizontal scaling in a relational database can be achieved through techniques such as sharding, where data is distributed across multiple servers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is database sharding, and when would you use it?

A

Database sharding is the process of splitting a database into smaller, more manageable pieces called shards, which can improve performance and scalability.

Sharding is often used when dealing with large datasets or high-traffic applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does a distributed database ensure consistency in a multi-node environment?

A

A distributed database ensures consistency through protocols like CAP theorem, which balances consistency, availability, and partition tolerance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the differences between a database index and a materialized view?

A

A database index improves query performance by providing quick access to rows, while a materialized view stores the result of a query for faster retrieval.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between write-ahead logging (WAL) and journaling?

A

Write-ahead logging records changes before they are applied, ensuring data integrity, while journaling logs changes after they are made, primarily for recovery purposes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you manage database replication and failover?

A

Database replication can be managed using master-slave configurations, while failover involves switching to a standby database in case of failure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain the differences between database isolation levels.

A

Database isolation levels define how transaction integrity is visible to other transactions, with levels including Read Uncommitted, Read Committed, Repeatable Read, and Serializable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does a query execution plan help in optimizing database performance?

A

A query execution plan outlines the steps the database engine will take to execute a query, helping identify bottlenecks and optimize performance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the trade-offs of using SQL vs. NoSQL databases for different workloads?

A

SQL databases provide strong consistency and structured data handling, while NoSQL databases offer flexibility and scalability for unstructured data.

The choice depends on specific application needs and workloads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly