[英]Representing a super column in Cassandra CQL
Currently, I have the following schema for one of my tables: 目前,我的一个表有以下模式:
id
name
...
country
- id
- name
- city
- id
- name
I was looking around the Cassandra documentation, and I cannot find any clear examples or demonstrations as to how I would represent my super columns in a column family. 我正在查看Cassandra文档,我找不到任何明确的示例或演示如何在列系列中表示我的超级列。 The code I have is as follows: 我的代码如下:
CREATE COLUMNFAMILY table (
id varint,
name varchar,
<<regular columns omitted>>
country ..?,
PRIMARY KEY = (id)
);
You can create a user-defined type to attach multiple data fields to a column. 您可以创建用户定义的类型以将多个数据字段附加到列。
For example, in your case 例如,在你的情况下
country
- id
- name
- city
- id
- name
Can be represented in a UDT as 可以在UDT中表示为
CREATE TYPE mykeyspace.countryudt (
id uuid,
name text,
city map<uuid, text>
);
Now the table definition will look like, 现在表定义看起来像,
CREATE COLUMNFAMILY table (
id varint,
name varchar,
<<regular columns omitted>>
country frozen <countryudt>,
PRIMARY KEY = (id)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.