RECOMMENDED PATHS
ArchitectLOGIN TO START THIS PATH
VIEW COURSES
0%
DS101: Introduction to Apache Cassandra™
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™
DeveloperLOGIN TO START THIS PATH
VIEW COURSES
0%
DS101: Introduction to Apache Cassandra™
0%
DS201: DataStax Enterprise 6 Foundations of Apache Cassandra™
0%
DS220: DataStax Enterprise 6 Practical Application Data Modeling with Apache Cassandra™
Graph SpecialistLOGIN TO START THIS PATH
VIEW COURSES
0%
DS101: Introduction to Apache Cassandra™
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
UNIT CONTENTS
Unit Status
 
 
  Previous Unit: Collections
Finish & Next Unit: Counters  

DSE Version: 6.0

UDTs

Video

In this unit you will be learning about UDTs, or User Defined Types. These are useful if you need to store a more complex data structure wihin a single cell in your table.

Transcript: 

Alright, let’s say you need to store a more complex data structure within a single cell in your table, you might not be able to do that with a collection and you might move onto to using a user defined type, affectionately known here as a UDT.  UDTs allow you to group related fields of data together and are named and type. UDTs can be include any supported data types included collections and other UDTs Allows embedding of more complex data within a single column, adding flexibility to your table and data model.

Let’s take a look at some examples here.  First I create the types. Wow, this looks eerily similar to create a table.  Huh. Anyway. Here I am creating an address type which has street, city, zip and a set of phone numbers.  Now all of these fields I created make up a single address. Let’s imagine that several of our users have the same address.  Well in the relational world, you would have a users table and an address table and you’d have to join these two together. Well, cassandra’s denormalization technique would be to embed the address in a single cell of the users table.  There’s a second small UDT example here where we have “full name” which is made up a user’s first name and their last name.

Okay, so now what?  We created our types, how do we use those in our tables?  Well, next you see our create table definition here on this slide.  Notice we used our full_name UDT in our “name” column. Next line down we created a SET collection type with our full_name UDT to create a direct_reports column.  And finally, we used our address UDT in a MAP collection.

UDTs might take a little practice, so take some time now to go do the exercise!

No write up.
No Exercises.
No FAQs.
No slides.
No resources.