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)
What is schema design in database context?
Schema design refers to the structure and organization of a database, including tables, relationships, keys, and constraints.
What are soft deletes?
Soft deletes mark records as deleted without actually removing them from the database, typically using a ‘deleted’ flag.
What are hard deletes?
Hard deletes permanently remove records from the database, which cannot be recovered without backups.
What is a common disadvantage of soft deletes?
Soft deletes can clutter the database with stale data, leading to performance issues if not properly managed.
What is a common advantage of hard deletes?
Hard deletes free up storage and simplify queries by removing unnecessary data.
What is a best practice for data archiving?
Archive old data in separate tables or databases to keep active data manageable while preserving historical records.
What is denormalization in practice?
Denormalization is the process of adding redundancy to a database to improve read performance at the cost of additional storage and potential update anomalies.
What’s a real-world use case for denormalization?
In OLAP systems, denormalization helps speed up complex queries and analytics by reducing joins.
What is a query optimization walkthrough?
A query optimization walkthrough involves analyzing and refining a SQL query to reduce resource consumption, improve speed, and avoid common pitfalls.
What are common steps in query optimization?
Identify slow queries, examine execution plans, adjust indexes, and refactor queries for better efficiency.
What is data migration from Oracle to Postgres?
Data migration involves transferring schema, data, and business logic from an Oracle database to a PostgreSQL system, requiring compatibility checks and transformations.
What is the challenge of data consistency across services?
Ensuring consistency in distributed systems, especially with eventual consistency models, can be difficult, requiring strategies like eventual consistency, replication, and synchronization.
What are best practices for ensuring data consistency?
Use of transactions, distributed locks, idempotent operations, and tools like Kafka or Saga pattern for consistency in microservices.
What is the impact of schema design on system performance?
Good schema design ensures fast queries, efficient indexing, and manageable storage, while poor design can lead to slow performance and data integrity issues.
What is the architectural implication of data archiving?
Archiving old data allows the active database to stay small and fast, while historical data is available when needed for compliance or analysis.
What is the performance tradeoff with soft deletes?
While soft deletes prevent data loss, they can lead to bloated tables and slower queries due to the need to filter out ‘deleted’ records.
What’s a fault tolerance tradeoff when migrating from Oracle to Postgres?
Migrating may lead to temporary downtime or data inconsistencies if not properly tested or handled during migration.
What is a real-world tradeoff with denormalization?
Denormalization boosts query performance but increases the risk of update anomalies and data inconsistency due to redundant data.
What’s a common interview question on schema design?
Can you describe how you would design a schema for a multi-tenant application?
What’s a common gotcha with data migration?
Differences in data types, constraints, or SQL syntax between systems (like Oracle and Postgres) can lead to errors if not accounted for.
What’s an example of using soft deletes in practice?
E-commerce platforms often use soft deletes for product listings to avoid data loss in case items are mistakenly removed.
What is the impact of query optimization on system design?
Optimized queries reduce load on the database, improve application performance, and ensure scalability in high-traffic systems.
What’s a common mistake in data consistency across services?
Not handling data synchronization properly, leading to eventual consistency issues where different services have inconsistent views of the data.
What is a real-world scenario for SQL in a database system?
Real-world scenarios include data retrieval from large tables, complex reporting, and transactional processing in high-traffic applications like e-commerce platforms.