- Learning Apache Cassandra(Second Edition)
- Sandeep Yarabarla
- 213字
- 2021-07-03 00:19:36
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.
- 亮劍.NET:.NET深入體驗與實戰(zhàn)精要
- Hands-On Internet of Things with MQTT
- Microsoft Power BI Quick Start Guide
- 大數(shù)據(jù)專業(yè)英語
- 極簡AI入門:一本書讀懂人工智能思維與應用
- Apache Hive Essentials
- Ruby on Rails敏捷開發(fā)最佳實踐
- 新編計算機組裝與維修
- FPGA/CPLD應用技術(Verilog語言版)
- Salesforce Advanced Administrator Certification Guide
- 重估:人工智能與賦能社會
- 工業(yè)機器人力覺視覺控制高級應用
- 無人駕駛感知智能
- Effective Business Intelligence with QuickSight
- 網(wǎng)管員世界2009超值精華本