# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://knowledgebase.qommentary.com/qommentary-writeback/defining-a-primary-key.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
