Real-World Scenarios & Interview Challenges Flashcards

Schema design case studies Soft deletes vs hard deletes Data archiving strategies Denormalization in practice Query optimization walkthroughs Data migration (e.g., Oracle to Postgres) Data consistency across services (41 cards)

1
Q

What is schema design in database context?

A

Schema design refers to the structure and organization of a database, including tables, relationships, keys, and constraints.

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

What are soft deletes?

A

Soft deletes mark records as deleted without actually removing them from the database, typically using a ‘deleted’ flag.

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

What are hard deletes?

A

Hard deletes permanently remove records from the database, which cannot be recovered without backups.

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

What is a common disadvantage of soft deletes?

A

Soft deletes can clutter the database with stale data, leading to performance issues if not properly managed.

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

What is a common advantage of hard deletes?

A

Hard deletes free up storage and simplify queries by removing unnecessary data.

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

What is a best practice for data archiving?

A

Archive old data in separate tables or databases to keep active data manageable while preserving historical records.

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

What is denormalization in practice?

A

Denormalization is the process of adding redundancy to a database to improve read performance at the cost of additional storage and potential update anomalies.

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

What’s a real-world use case for denormalization?

A

In OLAP systems, denormalization helps speed up complex queries and analytics by reducing joins.

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

What is a query optimization walkthrough?

A

A query optimization walkthrough involves analyzing and refining a SQL query to reduce resource consumption, improve speed, and avoid common pitfalls.

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

What are common steps in query optimization?

A

Identify slow queries, examine execution plans, adjust indexes, and refactor queries for better efficiency.

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

What is data migration from Oracle to Postgres?

A

Data migration involves transferring schema, data, and business logic from an Oracle database to a PostgreSQL system, requiring compatibility checks and transformations.

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

What is the challenge of data consistency across services?

A

Ensuring consistency in distributed systems, especially with eventual consistency models, can be difficult, requiring strategies like eventual consistency, replication, and synchronization.

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

What are best practices for ensuring data consistency?

A

Use of transactions, distributed locks, idempotent operations, and tools like Kafka or Saga pattern for consistency in microservices.

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

What is the impact of schema design on system performance?

A

Good schema design ensures fast queries, efficient indexing, and manageable storage, while poor design can lead to slow performance and data integrity issues.

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

What is the architectural implication of data archiving?

A

Archiving old data allows the active database to stay small and fast, while historical data is available when needed for compliance or analysis.

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

What is the performance tradeoff with soft deletes?

A

While soft deletes prevent data loss, they can lead to bloated tables and slower queries due to the need to filter out ‘deleted’ records.

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

What’s a fault tolerance tradeoff when migrating from Oracle to Postgres?

A

Migrating may lead to temporary downtime or data inconsistencies if not properly tested or handled during migration.

18
Q

What is a real-world tradeoff with denormalization?

A

Denormalization boosts query performance but increases the risk of update anomalies and data inconsistency due to redundant data.

19
Q

What’s a common interview question on schema design?

A

Can you describe how you would design a schema for a multi-tenant application?

20
Q

What’s a common gotcha with data migration?

A

Differences in data types, constraints, or SQL syntax between systems (like Oracle and Postgres) can lead to errors if not accounted for.

21
Q

What’s an example of using soft deletes in practice?

A

E-commerce platforms often use soft deletes for product listings to avoid data loss in case items are mistakenly removed.

22
Q

What is the impact of query optimization on system design?

A

Optimized queries reduce load on the database, improve application performance, and ensure scalability in high-traffic systems.

23
Q

What’s a common mistake in data consistency across services?

A

Not handling data synchronization properly, leading to eventual consistency issues where different services have inconsistent views of the data.

24
Q

What is a real-world scenario for SQL in a database system?

A

Real-world scenarios include data retrieval from large tables, complex reporting, and transactional processing in high-traffic applications like e-commerce platforms.

25
What is an advantage of using SQL for data querying?
SQL provides a standardized and efficient way to query and manipulate relational data, allowing for powerful aggregation and filtering operations.
26
What is a disadvantage of SQL in large-scale systems?
SQL queries can become slow as data grows, and managing joins and complex queries may impact performance in large-scale distributed systems.
27
What is the best practice for indexing in SQL?
Create indexes on columns that are frequently used in search conditions, JOINs, and ORDER BY clauses to improve query performance.
28
What is a common use case for SQL in data-driven applications?
SQL is commonly used in web applications for tasks like user authentication, order processing, and inventory management.
29
How does SQL impact system design?
SQL allows for relational modeling, enforcing data integrity through constraints, which aids in building structured and reliable database systems.
30
Can you provide an example of an SQL join?
A common example is using an INNER JOIN to combine two tables, such as a 'Customers' table and an 'Orders' table, to retrieve customer order history.
31
What is the architectural implication of using SQL databases?
SQL databases follow a structured schema that enforces data consistency, which can help ensure accuracy and reduce errors but might hinder flexibility.
32
What is the performance tradeoff when using SQL databases in large systems?
SQL databases are highly consistent but may face performance bottlenecks as data volume grows, requiring careful indexing and query optimization.
33
What are the fault tolerance considerations when using SQL?
SQL systems can provide fault tolerance through replication, transaction logs, and backups, but high availability configurations may add complexity.
34
How do you monitor SQL queries for performance?
You can use EXPLAIN plans in databases like PostgreSQL and MySQL to analyze query execution paths, identify bottlenecks, and optimize performance.
35
What are real-world tradeoffs with SQL performance?
Optimizing SQL queries often involves tradeoffs between performance and maintainability; heavily optimized queries may be harder to understand and maintain.
36
What is a common interview question about SQL performance?
How would you optimize a slow-running query in a database with millions of records?
37
What’s a potential gotcha with SQL joins in large datasets?
Joins on large datasets can lead to significant performance degradation if proper indexing or query optimization techniques are not applied.
38
What’s a real-world use case for SQL transactions?
SQL transactions are used in scenarios where multiple operations must be completed together, like processing payments or updating inventory in an e-commerce system.
39
How does SQL's ACID compliance impact system design?
ACID compliance ensures that SQL databases maintain data consistency, even in the event of system crashes, which is critical for transactional systems.
40
How do SQL and NoSQL databases differ in system design?
SQL databases enforce strict schema and relationships, which are beneficial for structured data, while NoSQL systems provide flexibility for unstructured or semi-structured data.
41
What is a potential gotcha when designing SQL-based systems for high availability?
Ensuring consistency across replicas in high-availability SQL setups can lead to issues like replication lag or data inconsistency if not carefully managed.