RECOMMENDED PATHS
ArchitectLOGIN TO START THIS PATH
VIEW COURSES
0%
DS201: DataStax Enterprise 6 Foundations of Apache Cassandra™
0%
DS210: DataStax Enterprise 6 Operations with Apache Cassandra™
0%
DS220: DataStax Enterprise 6 Practical Application Data Modeling with Apache Cassandra™
0%
DS101: Introduction to Apache Cassandra™
DeveloperLOGIN TO START THIS PATH
VIEW COURSES
0%
DS201: DataStax Enterprise 6 Foundations of Apache Cassandra™
0%
DS220: DataStax Enterprise 6 Practical Application Data Modeling with Apache Cassandra™
0%
DS101: Introduction to Apache Cassandra™
Graph SpecialistLOGIN TO START THIS PATH
VIEW COURSES
0%
DS201: DataStax Enterprise 6 Foundations of Apache Cassandra™
0%
DS220: DataStax Enterprise 6 Practical Application Data Modeling with Apache Cassandra™
0%
DS330: DataStax Enterprise 6 Graph
0%
DS101: Introduction to Apache Cassandra™
UNIT CONTENTS
Unit Status
 
 
  Previous Unit: Table Features
Finish & Next Unit: UDTs  

DSE Version: 6.0

Collections

Video

In this unit, yhou will be learning about the collections data types. Collections allow you to store multiple values in each cell, while still keeping the values in dividuality.

Transcript: 

Let’s start with the first data struction, collections.  Collections allow you to store multiple values in each cell while still keeping the item’s individuality.  Compare this to relational where multiple values are concatenated into one string separated by commas. Cassandra provides the same datatypes you find in other programming languages.

Some details on collections in general before I got into each one.  All collections are multi-valued columns. Collections are meant to store small amounts of data.  They are retrieved in their entirety. And you cannot next collections inside of other collections unless you use the FROZEN keyword.  More or FROZEN later, I promise.

Set stores a set of unique values. The list is stored un-ordered by is returned in a sorted order.  The type is in the angle brackets, and in our example here, we are using the text data type. Let’s look at an example here.  I created a users table with an id, first name, last name and a “set” of email addresses. It is common these days that people have more than one address.  First I create the table then I insert values into the table. Notice my example here, I have inserted two addresses for my user cass123.

Okay, let’s move onto LIST.  First of all, LIST is like SET in that it groups and stores values in a single cell. What makes them different is that they do not have to be unique and there can be duplicates in your list.  Also LISTS are stored in a particular order and are inserted or retrieved according to an index. Here’s a quick example of how I altered my users table to insert a list of frequent destinations users in my table like to go and I updated the user ‘cass123’ with the values Berlin, London and Paris.

Last collection type I will talk about is MAP.  Map is cool because it allows you to relate values to one another in a key/value pair.  Both the key and the value have a designated data type. Check out this example. I altered the table again to add a map called “to do” with the data types of “timestamp” and text.  And then I updated values for user cass123 again to have a to do list of of dates upon which to complete the todo list. For example, user “cass123” is going to create a database Jan 1st, load and test the database the next day and then a month later, move the database to production.

Okay, so a few slides ago, I talked about Frozen.  Can’t put it off any longer, so let me explain it now.  Let me summarize by saying, if you want to next data types, you have to use the FROZEN keyword.  Frozen allows you to serialize multiple components into a single value. Essentially turning that value into a blob.  If you want to update a single value in the collection, don’t use FROZEN.

Alright, I think that’s it on Collections!  Why don’t you take a few minutes to try these out with an exercise!

No write up.
No Exercises.
No FAQs.
No resources.
Comments are closed.