Course contentsShow
← System Design
Lesson 432 of 1,91912. NoSQL: Wide-Column StoresFree lesson

Data Modeling Best Practices

Query-first design, denormalization, and avoiding anti-patterns like wide rows and tombstones.

Data Modeling Best Practices

What you'll learn: How to design effective data models in wide-column stores by thinking query-first, embracing denormalization, and avoiding common pitfalls.

Query-First Design

In wide-column stores like Cassandra, you must design your tables around your queries, not around normalized entities. Unlike relational databases where you normalize first and query later, here you identify every query your application will perform, then create tables optimized for those specific access patterns. Each table becomes a materialized view tailored to answer one question efficiently.

Think of it like organizing a library: instead of one master catalog, you create separate specialized indexes—one sorted by title, another by author, another by publication date—because lookups are fast when data is pre-arranged for the exact question you're asking.

Embrace Denormalization

Wide-column stores thrive on data duplication. Store the same information in multiple tables optimized for different queries. Yes, this means redundancy, but it enables lightning-fast reads without expensive joins. Update multiple tables when data changes—trading write complexity for read performance.

Avoiding Anti-Patterns

Wide rows occur when a single partition key accumulates too many clustering columns—imagine millions of columns in one row. This overwhelms individual nodes and slows reads. Solution: use time-bucketing or composite partition keys to distribute data.

Tombstones are deletion markers that accumulate when you frequently delete data. Too many tombstones poison read performance because Cassandra must scan through them. Avoid excessive deletes in the same partition; consider TTL-based expiration instead, or redesign to minimize deletions.

Key Takeaway: In wide-column stores, design tables for specific queries, denormalize freely to avoid joins, distribute data across partitions to prevent wide rows, and minimize deletions to avoid tombstone buildup.