## Defining schema for data creation and validation

The routines for building and validating databases are driven by format specifications defined in a `tables_defs.json` file. That file defines the tables, fields, and field properties used in the database. For example:

```perl
{
  "datasources":   {
    "datasources_id": ["integer", true,true, null],
    "source": ["text", true, true, null],
    "url": ["text", false,false, null],
    "methoddescription": ["text", false,false, null],
    "notes": ["text", false, false,null]
  },
  "descriptionofmodelelements": {
    "descriptionofmodelelements_id": ["integer", true,true, null],
    "modelelement": ["text", true,true, null],
    "name": ["text", true,true, null],
    "age": ["text", true,false, null],
    "description": ["text", true,false, null],
    "hierarchykey": ["text", true,true, null],
    "datasourceid": ["integer", true,false, "datasources(datasources_id)"]
  },
}
```
Where the structure of these is:

```perl
"tablename":   {
    "tablename_id": ["data type", "is not null?","is unique?", "references table (reference column)"],
}
```

The following assumptions are made:
1. a `tablename_id` field is present. This is intended to serve as the primary key (though this can't quite be set up as such in geodatabases)
    - [ ] TODO: Perhaps these should just be made by default
2. all geometry columns are listed with field name `"geom"` and use WKT names for geometry types
3. all datatypes are consistent with the geopackage/sqlite3 standard (the mapping to ESRI geodatabase datattypes is provided in the `config.py` file)


Similarly, a `standard_vals.json` file describes standard values to insert into certain tables. It maps a table name to a dictionary of `fields` (those fields where values will be inserted) and `values` (a list of lists of corresponding values to insert). For example:
```perl
{
  "measurementunits": {
    "fields": ["unit", "multiplier_to_meters"],
    "values": [
      ["meters", 1.0],
      ["feet", 0.3048],
      ["kilometers", 1000.0],
      ["miles", 1609.34],
      ["yards", 0.9144],
      ["furlongs", 201.168],
      ["inches", 0.0254]
    ]
  },
  }
```