﻿# SQLite UNIQUE does not require complete synthetic entity keys

A practical investigation of sQLite UNIQUE does not require complete synthetic entity keys, with explicit observations, control cases and evidence limits.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/field-synthetic-sqlite-unique-null-generated-entity-key-completeness/
Language: en

## The generated-data scenario

A generator stages synthetic entities in SQLite with a unique external-key column and assumes successful inserts prove every entity has a usable deduplication key. Missing keys are stored as NULL. Multiple such rows can be accepted, so a retry or repeated entity may survive despite the uniqueness constraint. The investigation separates complete identity from uniqueness among values the index actually constrains as equal.

## The generation mechanism

SQLite documents that NULL entries are considered distinct for unique indices. Its NULL-handling discussion contrasts this with SELECT DISTINCT and UNION, which collapse NULLs in those operations. These different rules explain why a deduplicated preview can look tidy while staged rows still lack usable identities. A unique index is not itself a requirement that every generated record supplies a nonmissing external key.

## Define the dataset contract

Define the external identity domain, missing-key policy and duplicate-record policy independently. If every released entity requires a key, enforce presence explicitly before or during admission. Keep rejected missing-key records traceable. Do not replace all missing keys with one ordinary string unless that representation is deliberately designed, because a placeholder can collide with valid data or falsely merge unrelated generated entities.

## A step-by-step protocol

Create a disposable fixture with repeated present keys, distinct present keys and repeated missing keys. Inspect actual insertion outcomes and the stored rows under the intended schema. Compare the index result with a DISTINCT preview as a diagnostic. Run the final release validator and student loader, confirming that missing identities are rejected or explicitly represented according to the declared dataset contract.

## Evidence required for acceptance

Acceptance requires both key-presence evidence and uniqueness evidence over the intended identity relation. Preserve outcomes for every attempted generated record, including retries. A row-count match alone cannot prove identity continuity when missing keys pass through. Inspect joins and split grouping because records without valid keys can be merged, lost or assigned inconsistent groups later even if the staging table accepted them.

## Failure cases and limits

This article describes SQLite semantics, not a universal rule for every database or custom index expression. Missing identity can be legitimate in some exploratory datasets if it remains explicit. The proposed protocol does not infer whether content duplicates are semantically identical. It establishes whether the released corpus satisfies its stated key contract rather than borrowing that guarantee from the word UNIQUE in a schema.

## Primary references and related reading

Validate key presence separately from uniqueness because NULL entries can coexist in a unique index. [SQLite UNIQUE index NULL semantics](https://www.sqlite.org/lang_createindex.html); [SQLite NULL uniqueness versus DISTINCT](https://www.sqlite.org/nulls.html).

The proposed investigation of sqlite unique null generated entity key completeness is a proposed dataset-contract review; no production dataset was generated or evaluated. Related reading: [Frictionless Table Schema: validate logical values before feature building](/journal/data-guide-frictionless-table-schema/); [Apache Arrow: nulls, empty lists and nested training features](/journal/data-guide-arrow-nullable-feature-contract/).
