Choosing the right database based on data v2.0 Flashcards

(5 cards)

1
Q

Before choosing a database

A

Are relationships strong and enforced?

Do you need foreign keys, constraints, cascades?

How often do you traverse relationships?

Frequent joins vs rare lookups

Is the access pattern predictable?

Known queries vs ad-hoc exploration

Do relationships evolve over time?

New entity types and edges added frequently?

Do you need transactions across relations?

ACID guarantees across multiple entities

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

Relational Databases

A

Best when:

Strong, well-defined relationships

Complex joins are common

Referential integrity matters

ACID transactions required

Why it fits

JOINs are first-class

Foreign keys + constraints

Query planner optimizes relational traversal

Be careful when:

Graph depth becomes large (5–6 joins)

Read patterns are highly denormalized

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

Document Store (MongoDB, Couchbase)

A

Useful for aggregate bound relationships
A relationship is aggregate-bound when:
One entity owns the others
Child entities have no meaning outside the parent
All lifecycle operations go through the aggregate root
Order (Aggregate Root)
├── OrderItem
├── OrderItem
└── ShippingAddress

Rule of thumb - If a child entity cannot be safely updated without its parent, the relationship is aggregate-bound.

When relationships are aggregate-bound:

✔️ Embed data
✔️ Fetch as one unit
✔️ Avoid joins

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

Graph Databases

A

Best when:
Relationships are the data
Deep, variable traversal
Queries like “friends of friends of friends”
Natural for network-like data

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

Column Store (Cassandra, Bigtable)

A

Relationships are query-driven
Writes are high-volume
Reads have predictable patterns
Use this when
Event logs
Time-series relationships
Analytics ingestion

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