> For the complete documentation index, see [llms.txt](https://knowledgebase.qommentary.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://knowledgebase.qommentary.com/qommentary-writeback/defining-a-primary-key.md).

# Defining a primary key

A primary key dimension is a field which contains keys unique for each record. When you add dimensions to your Qommentary Writeback table, you will need to select one dimension to be used as the **primary key**.

To select a dimension to be used as a primary key, please follow these steps:

1\. Add a dimension to your table

<div align="left"><img src="/files/-MYeeJZ3xS47WBkDNBpE" alt=""></div>

2\. Expand the dimension's properties\
3\. Click on the switch control to select dimension as **Primary key dimension**

<div align="left"><img src="/files/-MYeelqUCcGxzmXBasiN" alt=""></div>

{% hint style="warning" %}
Be aware of any additional dimensions added which could split the primary key dimension forcing it to display duplicated values - thus breaking the primary key purpose.&#x20;

In that case, consider creating a **composite key**.
{% endhint %}

### Using a single dimension

When the dimension chosen to act as a primary key displays unique records in the table, then selecting a single dimension is sufficient.

Example:\
&#x20;<img src="/files/-MYegToQu6PukfcHUrMh" alt="" data-size="original">&#x20;

### Using a composite dimension

When a single dimension cannot produce unique records, then a composite dimension must be created.&#x20;

Example:\
&#x20;<img src="/files/-MYehMDwnTz-mHNfCLsw" alt="" data-size="original">&#x20;

{% hint style="info" %}
You may hide the column if you do not wish to display it in your table.
{% endhint %}
