> For the complete documentation index, see [llms.txt](https://docs.quanti.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.quanti.io/key-concepts/fundamental-concepts/primary-key.md).

# Primary key

The **Primary Key (PK)** is the set of fields that **uniquely** identify a row in your table.

**Concrete examples:**

**Daily metrics table** (fact table)

```
Primary Key: (date, campaign_id, ad_id)
```

| date       | campaign\_id | ad\_id  | impressions | clicks |
| ---------- | ------------ | ------- | ----------- | ------ |
| 2025-01-15 | camp\_123    | ad\_456 | 1000        | 50     |
| 2025-01-15 | camp\_123    | ad\_789 | 800         | 30     |

Each combination (date + campaign\_id + ad\_id) identifies a unique row.

**Campaign attributes table** (dimension table)

```
Primary Key: (campaign_id)
```

| campaign\_id | name            | status | budget |
| ------------ | --------------- | ------ | ------ |
| camp\_123    | Summer Campaign | ACTIVE | 5000   |
| camp\_456    | Winter Campaign | PAUSED | 3000   |

Each campaign\_id identifies a unique campaign.

{% hint style="info" %}
Why is this important?

The Primary Key concept allows you to define which table attributes identify each row as unique. This is essential for:

* **Determining the behavior of the UPSERT method**: should an existing row be updated or should a new row be inserted?
* **Avoiding duplicates** in your tables
* **Guaranteeing the uniqueness of each row and data integrity**, two essential concepts in data management
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://docs.quanti.io/key-concepts/fundamental-concepts/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.
