opengeospatial / geopackage-related-tables

A proposed GeoPackage extension for related tables
Other
3 stars 6 forks source link

Consider adding SQL constraints for cardinality column #19

Closed bradh closed 6 years ago

bradh commented 6 years ago

The cardinality column has a limited range of values. That could be enforced by SQL triggers as we have for the base spec.

rcasscslt commented 6 years ago

Something like? -note extra not null on mapping_table_name:

CREATE TABLE 'gpkgext_relations' (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  base_table_name TEXT NOT NULL,
  base_primary_column TEXT NOT NULL DEFAULT 'id',
  attribute_table_name TEXT NOT NULL,
  attribute_primary_column TEXT NOT NULL DEFAULT 'id',
  relation_name TEXT NOT NULL,
  mapping_table_name TEXT NOT NULL UNIQUE,
  cardinality TEXT NOT NULL CHECK( cardinality in ('many-to-many','many-to-one','one-to-many'))
 );
bradh commented 6 years ago

Yep.

Ref: mapping_table_name not null PR at #18.

jyutzler commented 6 years ago

Fixed by https://github.com/jyutzler/geopackage-related-tables/commit/2f4e5c0a0c8a6c3ecd2f84497b5c1de3066677d6