---
title: "Looker joined views with no primary key | Metacenta"
description: "Without a primary key Looker cannot apply symmetric aggregates, so a joined sum is silently multiplied. Which views need one, and how to add a key."
url: "https://metacenta.com/rules/lookml-joined-view-no-primary-key"
updated: "2026-10-14"
tokens: 619
---

BI semantic layer · rule lookml-joined-view-no-primary-key

# Looker joined views with no primary key

A Metacenta review checks this under the rule **A joined view declares a primary key**. Everything below applies whether or not you ever commission one.

## What this rule checks

This rule flags each view taking part in a join, the explore's base view included, that declares no `primary_key: yes`. A bare join (`sql: ;;`) brings in no rows, so it doesn't count. Unjoined views aren't judged.

## Why it matters

Without a key Looker cannot apply symmetric aggregates. A sum or average over the view is silently multiplied when a join fans out its rows. The dashboard shows a confident, wrong number.

## How to fix it

**Declare a primary key on every joined Looker view.** Mark the view's unique dimension with `primary_key: yes`. If there is no single unique column, build a compound key in a dimension and mark that. A joined view built on a [Looker derived table](https://metacenta.com/rules/lookml-sql-derived-table) needs a key too.

Before:

```lookml
view: order_items {
  dimension: order_item_id {
    sql: ${TABLE}.order_item_id ;;
  }
}
```

After:

```lookml
view: order_items {
  dimension: order_item_id {
    primary_key: yes
    sql: ${TABLE}.order_item_id ;;
  }
}
```

## When it is fine to leave

Where every join declares `many_to_one` or `one_to_one`, rows cannot fan out today. We rate that lower, but the key still protects against a relationship someone later gets wrong. It costs one line.

## What we need to check it

The `.lkml` files. A key can sit in a refinement or in a base the view `extends`. When that file was not supplied, we leave the view unexamined rather than flag it. Findings are medium confidence.

[Ask about a review](https://metacenta.com/enquire?src=rule-lookml-joined-view-no-primary-key&via=md)

## Related pages

- [dbt semantic models reading unbuilt columns](https://metacenta.com/rules/semantic-column-not-built)
- [dbt semantic model keys with no unique test](https://metacenta.com/rules/semantic-primary-entity-unasserted)
- [Looker views reading tables dbt does not know](https://metacenta.com/rules/lookml-view-unbuilt-table)
- [Looker views reading raw dbt sources](https://metacenta.com/rules/lookml-view-reads-raw-source)
- [A sample review, as a client reads it](https://metacenta.com/sample)
- [All published rules](https://metacenta.com/rules)
- [How a review is assessed](https://metacenta.com/standard)
