ScyllaDB in Action cover
welcome to this free extract from
an online version of the Manning book.
to read more
or

4 Data types in ScyllaDB

 

This chapter covers

  • The basic types ScyllaDB uses to store strings, numbers, dates, IDs, and more
  • The collection types Scylla uses to aggregate data
  • When to use each of these types to fit your design’s needs

In the last chapter, you learned about query-first design, using it to expand your restaurant review database into the beginnings of a database schema for a full-blown restaurant review application. Starting with the requirements, you determined the queries your app needed to run, the tables those queries run against, and the primary keys for those tables. The chapter ended on a cliffhanger: what data goes into those tables, and what are the data types associated with that data? Here, you’ll learn the answer to those great mysteries.

In this chapter, you’ll focus on the fifth question of query-first design (figure 4.1): what data goes in these tables? To answer this question, you need to know what data types ScyllaDB supports so that you can best represent your data in your schema.

Figure 4.1 Having designed your tables and queries, it’s time to determine the data types and fields you need to store.
figure

The most basic building blocks of data modeling are the values and the types you give them. In Scylla, every column has a type, and every value in that column shares that type. Scylla supports a rich variety of types—more than just numbers and text. In this chapter, you’ll explore the tools you have to give meaning to your data.

4.1 Preparing yourself

4.1.1 Data-type playground

4.1.2 Identifying the fields

4.2 The most common types: Text and numbers

4.2.1 Text

4.2.2 Numbers

4.3 Dates and times

4.3.1 Working with dates and times

4.3.2 Durations

4.3.3 When to use timestamps, dates, and times

4.4 IDs

4.4.1 UUIDs

4.4.2 Picking an ID type

4.5 Collections

4.5.1 Lists

4.5.2 Sets

4.5.3 Maps

4.5.4 User-defined types

Summary