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

User-defined types


Using a tuple column to group educational information into a single column has several advantages, but there's also something missing. The education column comprises two components: the first, a string, is the name of an educational institution, and the second, an integer, is a graduation year. As the developers of the MyStatus application, we know what the two components of the tuple represent; however, this knowledge is not made explicit anywhere in the database definition.

To solve this problem, we can instead use a user-defined type. User-defined types are very similar to tuples, except that each component has a name. This makes it easier for application developers to easily infer the intent of a user-defined type. As we'll see shortly, user-defined types offer a couple of other advantages over tuples.

Creating a user-defined type

Whereas tuples are specified ad hoc when declaring the type for a column, user-defined types are defined separately and then referred to by...