现在我正在学习Cassandra,所以我得到了一张没有主键的桌子.但它有一些指数.
所以这是我的疑问,我可以创建一个没有主键的表.
CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid varchar,operatorproductid varchar,price float,fallback varchar,paymenttype varchar,operatorid varchar,subscriptiontype varchar,expiry timestamp,subscriptionstatus varchar,created timestamp);
没有主键,subscriberid,productid,operatorid和subscriptiontype是索引.这可能吗?
从文档中
Primary Key::
A primary key identifies the location and order of data storage. The primary key is defined at table creation
time and cannot be altered. If the primary key must be changed,a new table schema is created and the
data is written to the new table. Cassandra is a partition row store,and a component of the primary key,
the partition key,identifies which node will hold a particular table row.
At the minimum,the primary key must consist of a partition key. Composite partition keys can split a
data set so that related data is stored on separate partitions. Compound primary keys include clustering
columns which order the data on a partition.
The definition of a table’s primary key is critical in Cassandra. Carefully model how data in a table will
be inserted and retrieved before choosing which columns will define the primary key. The size of the
partitions,the order of the data within partitions,the distribution of the partitions amongst the nodes of the
cluster – all of these considerations determine selection of the best primary key for a table.