官术网_书友最值得收藏!

Defining static columns

To see how static columns work, we'll create a new table called users_with_status_updates. Our goal for this table is to contain both user profiles and users' status updates; however, we only want one copy of a user profile even though each user might have many status updates. To accomplish this, we'll add all of the columns from both users and user_status_updates to our new table, but we'll declare the user profile columns as STATIC:

CREATE TABLE "users_with_status_updates" ( 
"username" text,
"id" timeuuid,
"email" text STATIC,
"encrypted_password" blob STATIC,
"body" text,
PRIMARY KEY ("username", "id")
);

Since the email and encrypted_password columns are properties of a user and not of a specific status update, we declare them STATIC. Any column that is declared STATIC has one value per partition key. In other words, there will be exactly one email value associated with a given username in our table.

The goal of static columns is to allow rows that share a partition key value to share other data as well. For this to be useful, there must be multiple rows per partition key, which is another way of saying that there must be at least one clustering column. It's illegal to declare a static column in a table with no clustering columns.

主站蜘蛛池模板: 兰坪| 定结县| 白银市| 淄博市| 菏泽市| 淮阳县| 扎鲁特旗| 武宣县| 耿马| 岳阳县| 南通市| 辽宁省| 兰西县| 夹江县| 墨竹工卡县| 宝清县| 芒康县| 兴隆县| 巨鹿县| 疏勒县| 泸定县| 柘城县| 永川市| 绵阳市| 荥阳市| 北宁市| 台北县| 卢氏县| 额尔古纳市| 长治县| 南皮县| 洛隆县| 枞阳县| 秦皇岛市| 封开县| 伊金霍洛旗| 西和县| 武宁县| 班戈县| 株洲县| 井冈山市|