# How to create a table with 2 primary keys and 0 clustering keys

**URL:** <https://forum.scylladb.com/t/how-to-create-a-table-with-2-primary-keys-and-0-clustering-keys/2303>\
**Category:** ScyllaDB\
**Tags:** data-model\
**Created:** [July 15, 2024, 10:31am UTC](https://forum.scylladb.com/t/how-to-create-a-table-with-2-primary-keys-and-0-clustering-keys/2303 "2024-07-15T10:31:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mojtaba\_Arezoomand](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/mojtaba_arezoomand/32/1015_2.png) [@Mojtaba\_Arezoomand](https://forum.scylladb.com/u/Mojtaba_Arezoomand)\
**Post date:** [July 15, 2024, 10:31am UTC](https://forum.scylladb.com/t/how-to-create-a-table-with-2-primary-keys-and-0-clustering-keys/2303/1 "2024-07-15T10:31:59Z")

</div>

Hello all,  
In the tutorials provided in the scylla university, it says that it is possible to have one or more primary keys and 0 or more clustering keys.

In the example provided for compound keys in scylladb you can define a table like this:

```auto
CREATE TABLE heartrate_v1 (
   pet_chip_id uuid,
   time timestamp,
   heart_rate int,
   PRIMARY KEY (pet_chip_id, time)
);

```

In this example, it creates a table with a primary key with `pet_chip_id` and with a clustering key on `time` column.

I have two questions:

1. How can I make `time` to be part of the primary key not clustering key?
2. Why can I have two rows with the same `pet_chip_id` but different `time`? Since time is part of the clustering key and is only used for sorting, why is it also used for identifying rows like primary keys?

Thank you so much

---

<div class="post-metadata">

**Author:** ![Botond\_Denes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/botond_denes/32/163_2.png) [@Botond\_Denes](https://forum.scylladb.com/u/Botond_Denes)\
**Post date:** [July 17, 2024, 5:17am UTC](https://forum.scylladb.com/t/how-to-create-a-table-with-2-primary-keys-and-0-clustering-keys/2303/2 "2024-07-17T05:17:51Z")

</div>

> - How can I make `time` to be part of the primary key not clustering key?

Add one additional set of parenthesis, like this:

```cql
CREATE TABLE heartrate_v1 (
   pet_chip_id uuid,
   time timestamp,
   heart_rate int,
   PRIMARY KEY ((pet_chip_id, time))
);

```

In general, an extra set of parenthesis can be used to delineate the partition key from the clustering key: `PRIMARY KEY ((partition_key_col1, partition_key_col2), clustering_key_col1, clustering_key_col2)`. The part in the inner parenthesis is the partition key.

---

<div class="post-metadata">

**Author:** ![Botond\_Denes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/botond_denes/32/163_2.png) [@Botond\_Denes](https://forum.scylladb.com/u/Botond_Denes)\
**Post date:** [July 17, 2024, 5:19am UTC](https://forum.scylladb.com/t/how-to-create-a-table-with-2-primary-keys-and-0-clustering-keys/2303/3 "2024-07-17T05:19:38Z")

</div>

> - Why can I have two rows with the same `pet_chip_id` but different `time`? Since time is part of the clustering key and is only used for sorting, why is it also used for identifying rows like primary keys?

Clustering keys are used for more than just sorting, they identify rows, just like partition keys identify partitions. Clustering keys allow you to have many rows within the same partition. If you want a single row in a partition, don’t define a clustering key.
