# ENS Unigraph SQL

The **ENS Unigraph** combines every ENSv1 "Nametable" (the mainnet ENS Registry, Basenames on Base, Lineanames on Linea, 3DNS on Optimism, and more) and the ENSv2 "Namegraphs" into a **single unified data model** — indexed into [ENSDb](/docs/services/ensdb), a standard PostgreSQL database.

**ENS Unigraph SQL** is direct, read-only SQL access to that data. The [ENS Omnigraph API](/docs/integrate/omnigraph) is built _on top of_ the Unigraph; Unigraph SQL is the layer beneath it, for use cases that go past what the Omnigraph exposes — custom analytics, data pipelines, dashboards, or building your own service. Because it's just Postgres, you can query it from **any language with a Postgres driver** — TypeScript, Python, Rust, Go, and more.
**Requires a self-hosted ENSNode:** SQL access connects directly to your ENSDb (PostgreSQL) instance, so you need to run your own
  ENSNode — NameHash's hosted instances don't expose direct database access. See the [self-hosting
  overview](/docs/self-host) to get an instance running. If you'd rather use a hosted API, reach for
  the [ENS Omnigraph API](/docs/integrate/omnigraph) instead.

## One model across ENSv1 and ENSv2

The Unigraph models both protocol versions with the **same polymorphic entities**, so the shape of your query rarely changes between an ENSv1 and an ENSv2 name:

- **Domain** — any name, on either protocol version. A `type` discriminator (`ENSv1Domain` / `ENSv2Domain`) tells you which, but the columns you read are shared.
- **Registry** — the contracts that hold subnames. ENSv1 and ENSv2 both follow the same `Registry → Domain → (sub)Registry → Domain → …` namegraph shape.
- **Account** — an address; owners, registrants, and permission holders all point here.
- **Registration** & **Renewal** — the lifecycle of a name, polymorphic across registration types (`.eth` `BaseRegistrar`, `NameWrapper`, 3DNS, and ENSv2 Registry registrations).
- **Resolver** records — indexed resolver state (addresses, text records, content hashes).
- **Label** — the `labelHash` → label mapping that heals hashed labels into human-readable names.
- **Permissions** — the ENSv2 roles model for who can do what in a specific contract.

## Get started

[Core Concepts](/docs/integrate/unigraph/concepts)

  [Examples](/docs/integrate/unigraph/examples)

  [Schema Reference](/docs/integrate/unigraph/schema-reference)

  [ENSDb (service)](/docs/services/ensdb)