Database Reference
In-Depth Information
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 con-
taining 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 to reuse a user-defined type across multiple columns in our
keyspace.
Note
For reference on user-defined types, refer to the DataStax CQL documentation: ht-
tp://www.datastax.com/documentation/cql/3.1/cql/cql_reference/cqlRefUDType.html
Search WWH ::




Custom Search