- Learning Apache Cassandra(Second Edition)
- Sandeep Yarabarla
- 268字
- 2021-07-03 00:19:33
The structure of the status updates table
The most notable aspect of user_status_updates is that it has two columns for a primary key. This means that each row is identified uniquely by the combination of its username and id columns. It also means that every row must have a value in both of these columns.
In addition to this, our user_status_updates table is the first time we've seen a timeuuid column in the wild. As you can recollect from the previous chapter, a UUID is essentially a very large number that is generated using an algorithm that guarantees that the identifier is unique across time and space.
You will also recollect that Cassandra does not have the ability to generate auto-incrementing sequences for use in primary keys as this would require an unacceptably high level of coordination between nodes in the cluster. In the users table, we used a natural key; we want each user to have a unique username, so the username column makes a perfectly good unique identifier for rows.
In the case of a status update, however, there is no obvious natural key. The only user-generated data associated with a status update is the body, but a free text field doesn't make a very good primary key, and anyway, there's no guarantee that status update bodies will be unique. This is where UUIDs come in handy. Since they're guaranteed to be unique, we can use them as a surrogate key—a unique identifier that isn't derived from the data in the row. Auto-incrementing primary keys in relational databases are also surrogate keys.
- 大學計算機信息技術導論
- Visualforce Development Cookbook(Second Edition)
- 三菱FX3U/5U PLC從入門到精通
- 協作機器人技術及應用
- 群體智能與數據挖掘
- 計算機網絡技術基礎
- Photoshop CS3圖層、通道、蒙版深度剖析寶典
- Photoshop行業應用基礎
- 基于神經網絡的監督和半監督學習方法與遙感圖像智能解譯
- Artificial Intelligence By Example
- Mastering Ansible(Second Edition)
- 21天學通Linux嵌入式開發
- 典型Hadoop云計算
- 筆記本電腦維修之電路分析基礎
- 電氣控制及Micro800 PLC程序設計