Polyglot Persistence & Use Cases Flashcards

Know when to combine SQL and NoSQL for the right architectural fit. Sample Interview Questions: "What is polyglot persistence and why is it useful?" "How would you design a system using both MongoDB and PostgreSQL?" Topics: Polyglot persistence: definition and benefits Choosing the right database per component Example architecture: product catalog in MongoDB + orders in PostgreSQL Event sourcing with NoSQL stores Data synchronization between SQL and NoSQL Best practices for multi-datab (23 cards)

1
Q

What is polyglot persistence?

A

Polyglot persistence is the practice of using different types of databases within a single system architecture to leverage the strengths of each for specific use cases.

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

Why is polyglot persistence useful?

A

It allows developers to optimize each component of a system by using the most suitable database for the job, improving performance, scalability, and flexibility.

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

When would you use polyglot persistence?

A

When different parts of an application have different data requirements, such as using MongoDB for flexible document storage and PostgreSQL for transactional integrity.

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

What are the benefits of polyglot persistence?

A

Better performance, flexibility, scalability, and the ability to match the right database to specific data access patterns and workloads.

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

What are the drawbacks of polyglot persistence?

A

Increased complexity in architecture, data synchronization, maintenance, monitoring, and consistency management.

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

How would you design a system using both MongoDB and PostgreSQL?

A

Use MongoDB for the product catalog to store flexible product data, and PostgreSQL for orders and transactions to ensure ACID compliance.

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

What is an example use case for combining MongoDB and PostgreSQL?

A

E-commerce platform: MongoDB for the dynamic product catalog and PostgreSQL for order processing and user data.

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

What is event sourcing and how does it relate to NoSQL?

A

Event sourcing stores state changes as a sequence of events. NoSQL databases like Cassandra or DynamoDB are often used for storing high-volume event data efficiently.

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

What is an example architecture using polyglot persistence?

A

Microservices-based system with: MongoDB for product metadata, Redis for caching, PostgreSQL for transactions, and Elasticsearch for search.

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

How do you synchronize data between SQL and NoSQL databases?

A

Use change data capture (CDC), event-driven architecture, or scheduled ETL jobs to ensure consistency and data flow between systems.

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

What are best practices for multi-database systems?

A

Clearly define ownership and purpose of each database, maintain consistent identifiers, automate synchronization, and monitor each system independently.

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

What is the impact of polyglot persistence on system design?

A

It introduces additional complexity in architecture, data flows, and maintenance, but enables optimal design per domain or microservice.

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

What are the performance considerations in polyglot persistence?

A

Latency and throughput may vary across databases; caching, batching, and asynchronous communication help reduce overhead.

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

What is a fault tolerance strategy in a multi-database setup?

A

Ensure each database has its own high availability mechanisms; use retry logic and fallback paths for data synchronization.

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

How do you monitor a polyglot persistence system?

A

Use distributed monitoring tools like Prometheus, Grafana, ELK stack, and database-native monitoring to track performance and availability.

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

How do you debug issues in a multi-database architecture?

A

Trace request flows using correlation IDs, inspect logs across services, and use monitoring data to isolate slow or failing database interactions.

17
Q

What are real-world tradeoffs in using multiple databases?

A

You gain optimized components and flexibility but must manage increased complexity, synchronization issues, and deployment overhead.

18
Q

What are common interview questions about polyglot persistence?

A

‘What is polyglot persistence?’, ‘Why combine SQL and NoSQL?’, ‘How do you keep data consistent across databases?’, ‘Give a real-world example.’

19
Q

What are potential gotchas with polyglot persistence?

A

Inconsistent data models, eventual consistency issues, increased ops overhead, lack of unified query capabilities, and testing challenges.

20
Q

What does ‘choosing the right database per component’ mean?

A

It means evaluating the needs of each system component (e.g., scalability, consistency, flexibility) and selecting the best database technology accordingly.

21
Q

What role does NoSQL play in event sourcing?

A

NoSQL databases like Cassandra or DynamoDB can efficiently store large volumes of immutable events with fast writes and scalable storage.

22
Q

What are architectural implications of polyglot persistence?

A

You must support multiple query languages, manage data flow and consistency between databases, and design services to isolate storage logic.

23
Q

What is an example of event sourcing with NoSQL?

A

A financial ledger system where each transaction is stored as an event in DynamoDB, with periodic snapshots in S3 for recovery.