Cassandra :: can I create a table without a primary key?

Now I'm learning Cassandra , so I got a table without a primary key . But it has some indexes.

So, this is my doubt, can I create a table without a primary key.?

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);

There are no main keys and subscribers, productid, operatorid and subscriptiontype are indexes. Is it possible?

From the documentation

Primary key:: The primary key determines the location and storage order of the data. The primary key is determined when the table is created and cannot be changed. If the primary key is to be changed, a new table schema is created and data is written to the new table. Cassandra is a repository of section strings and primary key components, a partition key determines which node will contain a particular table row. At a minimum, the primary key must consist of a partition key. Complex partition keys can be a data set so that related data is stored on separate partitions. Key keys include clustering columns that organize data on a partition. Defining the primary key of a table is crucial in Kassandra. Carefully model how the data in the table will be inserted and extracted before choosing,which columns will determine the primary key. Partition size, data order within partitions, partition distribution between cluster nodes — all these considerations determine the choice of the best primary key for a table.

+4
3

- ,

+4

. , , Cassandra. , Cassandra , , - ( ), , . Cassandra ( ) - node -local - Cassandra , node .

, , productid, operatorid subscriptiontype, 4 , , , productid, operatorid, . , cassandra , , .

, - .

(3.4 ) "SASI" - Cassandra, , .

+2

Cassandra . , (, "pk" ) UUID .

:

CREATE TABLE subscription (pk uuid PRIMARY KEY, subscriber varchar, productid varchar, panaccessproductid varchar, operatorproductid varchar, floating, backup varchar, paytype varchar, carrier varchar, subscription type varchar, expiration timestamp, statatus varch subscription, label);

and can insert data such as:

INSERT INTO subscription (pk, subscriber, ...) VALUES (uuid (), 'S123', ...);

+2
source

Source: https://habr.com/ru/post/1627105/


All Articles