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 name in column definitions. Let's make a user-defined type that we can use for our education column:

CREATE TYPE "education_information" (   "school_name" text,   "graduation_year" int );

Just like the tuple, we declared for our education column, this user-defined type contains two fields: a string containing the name of an educational institution, and an integer containing a year of graduation. Unlike the tuple, the type is declared independently of any particular table or column; it is a first-class entity within the my_status keyspace. This is advantageous when we want ...

Get Learning Apache Cassandra - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.