ScyllaDB University Live | Free Virtual Training Event
Learn more
ScyllaDB Documentation Logo Documentation
  • Server
  • Cloud
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
  • Resources
    • ScyllaDB University
    • Community Forum
    • Tutorials
Download
ScyllaDB Docs ScyllaDB Cloud Getting Started Documentation Design and Data Model

Design and Data Model¶

You can learn more about Data Modeling in Scylla (and NoSQL) by taking this course on Scylla University. The main goal of data modeling in Scylla is to perform queries fast, even if we sometimes have to duplicate data.

Let’s build our schema around the queries we are going to run against our domain entities. When creating the data model, you need to consider both the conceptual data model and the application workflow: which queries will be performed by which users and how often.

To achieve that, we want:

  • Even data distribution

  • To minimize the number of partitions accessed in a read query.

On the other hand, our focus won’t be on avoiding data duplication or minimizing the number of writes. You’re probably familiar with the steps defined here:

Conceptual Data Model¶

Starting with the conceptual data model, we need to identify the key entities and the relationships between them. Our application is focused in a single entity called ‘songs’. The concept is to fill with many songs as we want.

Table Diagram

Application Workflow¶

Next, we move on to the Application Workflow. In this part, we identify the main queries or what questions we will ask the database. This part is important in Scylla, and other NoSQL databases and, as opposed to relational databases is performed early on in the data modeling process. Remember that our data modeling is built around the queries.

Application Features¶

  • Insert a Song

  • List all songs

  • Delete a song

  • Stress Testing

Queries¶

Now we can detail the above queries in CQL:

Q1: Create a Keyspace

CREATE KEYSPACE prod_media_player
        WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '3'} 
        AND durable_writes = true;

Q2: Create a Table

CREATE TABLE songs (
        id int,
        title text,
        album text,
        artist text,
        created_at timestamp,
        updated_at timestamp
        PRIMARY KEY (id, updated_at)
);

Q3: Insert a new song

INSERT INTO prod_media_player.songs (id,title,artist,album,created_at) VALUES (?,?,?,?,?);

Q4: List all songs

SELECT * FROM pet WHERE songs

Q5: Delete a specific song

DELETE FROM songs WHERE id = ?

Helpful Material¶

Some more advanced topics not covered in this guide are Collections, User-DefinedTypes (UDT), expiring data with time to live (TTL), and Counters.

To summarize, when data modeling with Scylla, we have to know our data, think about our queries, pay attention to the primary key and clustering key selection, and not be afraid to duplicate data.

Was this page helpful?

PREVIOUS
Getting Started with ScyllaDB Cloud: A sample Media Player App
NEXT
Quick start: JavaScript (Node.js)
  • Create an issue
  • Edit this page

On this page

  • Design and Data Model
    • Conceptual Data Model
    • Application Workflow
    • Application Features
    • Queries
    • Helpful Material
ScyllaDB Cloud Getting Started Documentation
  • Getting Started
  • Design and Data Model
  • Build with JavaScript
  • Build with Java
  • Build with Elixir
  • Build with Python
  • Build with Ruby
  • Build with Rust
  • Build with Csharp
  • Build with Golang
  • Getting Started GitHub Repository
  • Alternator: Getting Started
  • Alternator: Build with PHP
  • Alternator: Build with Python
  • Getting Started GitHub Repository
Docs Tutorials University Contact Us About Us
© 2025, ScyllaDB. All rights reserved. | Terms of Service | Privacy Policy | ScyllaDB, and ScyllaDB Cloud, are registered trademarks of ScyllaDB, Inc.
Last updated on 05 May 2025.
Powered by Sphinx 7.4.7 & ScyllaDB Theme 1.8.6