Book Image

Learning Apache Cassandra

By : Matthew Brown
4 (1)
Book Image

Learning Apache Cassandra

4 (1)
By: Matthew Brown

Overview of this book

Table of Contents (19 chapters)
Learning Apache Cassandra
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with tuples


We saw that collections are a versatile tool for working with multiple values in a single column. One limitation of collections, however, is that all elements of a collection must be of the same type. If we want to store values of different types in the same collection, we can instead turn to tuples.

Unlike collections, which can store an arbitrary number of elements, a tuple column stores a fixed number of elements, each of which has a predefined type. So, while we gain the flexibility to store elements of different types in the same column, we give up flexibility in the number of elements stored.

Creating a tuple column

Let's say we'd like to allow users to add some information about their education to their profile. In particular, users should be able to enter where they went to university, and what year they graduated.

There are two distinct pieces of information here, namely school name and graduation year. However, the two are really two components of a single piece...