Extension Title

Contents Id

Introduction

This extension assigns a unique integer identifier to tables defined in the contents. Allows foreign key referencing to a contents (text based primary key) by an integer identifier. This extension is required because the gpkg_contents table "rowid table" rowid values are "not persistent and might change".

"If the rowid is not aliased by INTEGER PRIMARY KEY then it is not persistent and might change. In particular the VACUUM command will change rowids for tables that do not declare an INTEGER PRIMARY KEY. Therefore, applications should not normally access the rowid directly, but instead use an INTEGER PRIMARY KEY."

Extension Author

National Geospatial-Intelligence Agency, author_name nga

Extension Name or Template

nga_contents_id

Extension Type

New Requirement

Applicability

This extension applies to the table names of tables defined in the contents (1.1.3).

Scope

Read-write

Requirements

GeoPackage

Extension Table Entry

The Contents Id extension is registered into the gpkg_extensions table only once as follows:

gpkg_extensions
table_name column_name extension_name definition scope

null

null

nga_contents_id

URL to this extension description

read-write

Contents Id Table

The Contents Id Table contains an integer id and contents table name.

nga_contents_id
Column Name Type Description Null Default Key

id

INTEGER

Autoincrement primary key

no

PK

table_name

TEXT

The name of the actual content table, foreign key to gpkg_contents

no

FK,UK

CREATE TABLE nga_contents_id (
  id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  table_name TEXT NOT NULL,
  CONSTRAINT uk_nci_table_name UNIQUE (table_name),
  CONSTRAINT fk_nci_gc_tn FOREIGN KEY (table_name) REFERENCES gpkg_contents(table_name)
);
Contents Entry

The Contents Id Table defines a Contents row (2.4.2). This is required for use in the Related Tables Extension.

gpkg_contents
table_name data_type identifier description last_change min_x min_y max_x max_y srs_id

nga_contents_id

gpkg_extensions

nga_contents_id

date of last change

GeoPackage SQLite Configuration

None

GeoPackage SQLite Extension

None

Examples

The rivers GeoPackage has a contents id for the rivers feature table.

The example GeoPackage has contents id entries for all feature tables.