THE GOLD STANDARD OF GEOINFORMATICS
A code can fit the SQLite type and still violate the data contract
A habitat layer stores condition_code as an integer. SQLite accepts the value 8, the map opens and the attribute panel shows a number. The product dictionary allows only 1, 3, 5, 7 and 9. The file is readable, but one row no longer has a defined condition.
The GeoPackage schema extension can describe user-data columns and associate them with range, enumeration or glob constraints. These declarations improve interpretation and validation, but their presence does not guarantee that every writer enforced them. A clean schema table is evidence about the contract, not proof that all existing values satisfy it.
This guide builds a fictional field inventory, checks each constraint type, distinguishes labels from structural identifiers and then tests a round trip through a permissive editor. The goal is a handoff where a recipient knows both what values mean and whether the saved rows actually obey the declared rules.
The examples also keep invalid evidence instead of correcting it by guesswork. That lets a learner see whether a failure comes from storage type, constraint membership, text syntax, missing enforcement or an unresolved historical dictionary, while preserving stable keys and the original value for later review.
Geoinformatics subject guide · Learning that transfers into life · How X Works hub
Choose your reading route
Route 1 · Chapters 1–3: Describe the columns
Connect table fields to human meaning
Keep machine column names, reader-facing labels and code definitions in distinct roles.
Route 2 · Chapters 4–6: Validate the allowed values
Work enum, range and glob cases
Check actual rows and boundary conditions instead of trusting that declarations enforce themselves.
Route 3 · Chapters 7–9: Test editing and transfer
Verify the saved artifact, preserve unknown codes and document which layer performed enforcement.
Full chapter index · Independent worked case · Questions and practical checks
Chapter index
Describe the columns
1. Begin with a row definition and a field dictionary
2. Use gpkg_data_columns to connect semantics without renaming data
3. Build an enum from all allowed codes
CHAPTER 1 OF 9 · Describe the columns
1. Begin with a row definition and a field dictionary
Create a fictional feature table plots with integer plot_id, geometry shape, integer condition_code, numeric canopy_pct and text survey_tag. One row represents one surveyed plot. The geometry identifies its mapped support; the attributes describe a particular survey record under a stated dictionary.
Write the field definitions before the constraints. condition_code is an enumerated assessment class. canopy_pct is a percentage expected within a stated range. survey_tag follows a project naming pattern. A storage type such as INTEGER or TEXT does not carry all of that meaning.
Keep structural names stable. Applications and queries depend on condition_code, while a human-facing title can say Habitat condition. Translating or polishing the title should not rename the underlying column or change its code system.
Record missingness separately from allowed values. Null can mean not assessed if the table permits it. The integer zero should not automatically become missing; it may be prohibited, a valid class or a legacy code depending on the product definition.
Add five rows whose condition codes are 1, 3, 5, 7 and 9. Give canopy percentages 0, 25, 50, 75 and 100. Use survey tags S-2026-001 through S-2026-005. These values create positive controls before deliberate failures are introduced.
Practical evidence check
Create a compact dictionary with row unit, structural name, display title, storage type, null rule, code or unit definition and responsible source. Remove the column names and ask a reviewer whether the titles alone are enough to query the file; then remove the descriptions and ask whether storage types alone explain the values. The missing answers show why the layers of meaning must travel together.
CHAPTER 2 OF 9 · Describe the columns
2. Use gpkg_data_columns to connect semantics without renaming data
The schema extension’s gpkg_data_columns table can identify a table and column and add a short name, title, description, MIME type for appropriate BLOB content and an optional constraint name. The table supplements ordinary SQLite schema information; it does not replace the user column.
For condition_code, set a human-readable name and description that points to the fictional assessment scale. The constraint_name connects the column to rows in gpkg_data_column_constraints. That connection must use the declared lowercase name under the specification.
Check that table_name resolves to an allowed table or extension context and that column_name actually exists in the named table or view. A beautifully written description for a misspelled field is orphan metadata, not a repaired schema.
Do not store the full code meaning only in a translated title. Titles are helpful for a form, while enum constraint rows can carry per-value descriptions. Keep stable machine codes and accurate reader-facing explanations together so localisation does not alter the data values.
A field without a gpkg_data_columns row can still exist and be valid SQLite data. The extension is optional. The audit should say metadata absent rather than inventing constraints from observed values or from a familiar column name.
Practical evidence check
Compare every gpkg_data_columns row with the actual SQLite table or view and column. Flag orphan descriptions and real user columns that the product expected to describe but omitted. Change only a human title in a test copy and confirm queries still use the stable structural name. A localisation edit should not rewrite identifiers or constraint names.
CHAPTER 3 OF 9 · Describe the columns
3. Build an enum from all allowed codes
For condition_code, create an enum constraint named habitat_condition with permitted values 1, 3, 5, 7 and 9. Under the schema extension, enum rows sharing the same constraint name collectively define the possible values. Each value is case-sensitive text in the constraint table representation.
Test every allowed value and two prohibited values, 0 and 8. A validator should accept the five declared codes and flag the others. Checking only the current minimum and maximum would wrongly accept values 2, 4, 6 and 8 that lie inside the numeric span but are not members of the enum.
Attach descriptions such as excellent, good or review required only if the fictional dictionary defines them. Do not infer ordinal arithmetic from the code numbers. The difference between 1 and 3 may not be twice the difference between 7 and 9; codes can be categories rather than measured quantities.
If a legacy value 8 appears, preserve the original row and classify it. It may be a data error, an undocumented historical code or evidence that the wrong dictionary was attached. Replacing it with the nearest allowed number fabricates a meaning unless an authorised crosswalk exists.
For a changed-context check, use text codes A, B and C. Case sensitivity now becomes visible: a lower-case a is not automatically the same enum value. Decide whether normalisation is part of the product rules and apply it before or during validation with a recorded transformation.
Practical evidence check
Generate a test vector containing every enum member, two inside-but-undeclared numbers and one null. Validate membership rather than minimum and maximum. Preserve each enum description and test case sensitivity where text codes are used. If the tool sorts codes numerically, make sure that display behaviour is not mistaken for an ordinal scale.
CHAPTER 4 OF 9 · Validate the allowed values
4. Use range endpoints with deliberate boundary tests
For canopy_pct, create a range constraint from 0 to 100 with both endpoints inclusive. A valid row may therefore contain 0 or 100. These values can have physical or classification limits in the fictional exercise; they are not missing merely because they sit at an edge.
Test values minus 0.1, 0, 50, 100 and 100.1. The first and last should fail under the stated range. Boundary fixtures are more informative than a random middle value because they reveal whether inclusive flags were interpreted correctly.
Change the maximum to exclusive in a test definition. Now 100 fails even though the numeric min and max look unchanged. A user interface that displays only 0–100 without inclusivity can mislead an editor into accepting a value the contract excludes.
The specification requires range minima to be less than maxima. A single-value category should be an enum, not a range with equal endpoints. Choose a constraint type that reflects the data meaning rather than forcing every rule into numeric bounds.
A range does not establish measurement accuracy or unit. Values 0 through 100 can represent percentage, score or another quantity. Keep the unit and observational definition in the field description and product documentation.
Practical evidence check
For every range, test min minus a small step, min, one middle value, max and max plus a small step. Record endpoint inclusion. Repeat with null under the user-table null rule. If numeric precision matters, choose values that can be represented reliably in the receiving application and explain the comparison tolerance rather than hiding it in rounded interface text.
CHAPTER 5 OF 9 · Validate the allowed values
5. Use glob patterns for syntax, not semantic truth
For survey_tag, define a glob pattern matching a narrow fictional structure such as S-[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9]. It can test that a value resembles S-2026-001. Glob matching is a text pattern rule, not a full identity registry.
The tag S-2026-999 can match the pattern while referring to no known survey. Conversely, an existing authorised survey can fail if its legacy tag uses a different convention. Separate syntax validation from referential and business validation.
Test a lower-case prefix, a missing digit, an extra suffix and a correctly shaped value. Keep the expected outcomes with the pattern. A form that silently uppercases data has transformed the identifier and should record that behaviour.
Do not treat glob syntax as a universal regular expression language. Use the pattern semantics specified by SQLite and GeoPackage guidance. A pattern copied from a different regex engine can appear plausible and enforce a different set.
For a changed-context transfer, use document identifiers rather than survey tags. The same distinction survives: pattern checks format, while an authoritative register establishes existence and ownership. Passing the glob cannot prove the record is real.
Practical evidence check
Evaluate the glob with at least one valid value and failures for case, length, prefix and extra suffix. Then check the apparently valid value against the authoritative registry used by the fictional workflow. The first test addresses syntax; the second addresses existence. Keep their failure messages different so a user knows whether to correct formatting or investigate identity.
CHAPTER 6 OF 9 · Validate the allowed values
6. Do not assume declarations are automatically enforced
GeoPackage explains that schema constraints may be enforced by SQL triggers or by application code that updates user data. A package can contain a correct constraint declaration and still hold a prohibited value if a writer bypassed or failed to implement enforcement.
Open the test copy with a permissive SQLite editor and insert condition_code 8. The database engine may accept it because the user table has only an INTEGER type and no check trigger. The extension metadata has not magically rewritten the table definition.
Run a row-level validation after every import or edit. Join or compare user values to the constraint definitions under their actual type semantics. Report table, primary key, column, value and violated rule so the owner can investigate without guessing from a total failure count.
A strict application can reject the edit before save. Another can save and later flag the row. Both can participate in a controlled workflow if the behaviour is visible. What is unsafe is assuming enforcement happened because the schema tables exist.
Do not add triggers blindly to a production package. Triggers affect editing behaviour and need to conform to the extension and application requirements. Use supported tooling, authorised copies and tests that include bulk inserts, updates and null handling.
Practical evidence check
Insert one invalid value through each actual editing path: GIS form, bulk import and generic SQL tool if those paths are authorised. Record whether the value is blocked, warned, saved or normalised. Reopen the artifact and run row validation. This matrix identifies where enforcement lives and prevents a safe form from creating false confidence about an unrestricted import.
CHAPTER 7 OF 9 · Test editing and transfer
7. Keep SQLite typing and constraint semantics aligned
SQLite uses dynamic typing with column affinity rules. A value that looks numeric can be stored or compared in ways a reader does not expect. The schema constraint table stores enum and glob values as text, while range endpoints are numeric. Validation must follow the intended column type and applicable comparison semantics.
Test condition_code values inserted as integer 3 and text 3 under the actual application path. Do not decide equality from a visual attribute panel. Record whether the writer coerces values, preserves text or rejects the mismatch.
For a numeric range, test decimals and nulls. Nullability comes from the user table and product rule; it is not decided by the range endpoints. A null can be permitted while minus 1 is prohibited. Replacing null with zero changes both evidence and validation outcome.
For an enum used as category codes, avoid arithmetic operations unless the code system defines them. SQLite may happily average 1, 3 and 9. The result 4.33 is not automatically a meaningful habitat condition.
Include datatype observations in the validation receipt. A handoff that lists only values can miss a writer that converted identifiers to floating point or trimmed leading zeros from text codes.
Practical evidence check
Inspect storage class and logical meaning for representative values after round trip. Test an integer code entered as text, a leading-zero identifier and a decimal near a range edge. Compare what the UI shows with SQLite type inspection. If coercion is intentional, document it; if it changes identity, stop the workflow or choose a safer schema.
CHAPTER 8 OF 9 · Test editing and transfer
8. Round-trip labels, constraints and invalid fixtures
Open an authorised copy in the intended GIS, edit one permitted value and save. Close and reopen. Confirm the user row, gpkg_data_columns entry, constraint rows, descriptions and extension declaration all remain intact.
Next attempt a prohibited enum value, an out-of-range value and a malformed tag. Record whether the application blocks, warns, saves or strips the metadata. One successful permitted edit does not reveal how the writer handles invalid input or unfamiliar schema tables.
If the software exports to another format, inspect how the code dictionary travels. A shapefile, CSV or generic database may not carry the GeoPackage schema extension. Preserve an explicit data dictionary and validation results rather than assuming the target format inherits the rules.
Compare row counts and stable keys before and after. A filter that removes invalid rows can make the saved dataset look clean while hiding rejected evidence. Keep a quarantine or error report with the original keys and reasons when policy permits.
A round trip passes only for the declared operation. A reader can preserve metadata during a no-op save yet fail after renaming a field or changing the table. Test the changes the real workflow will perform.
Practical evidence check
Export to the recipient’s target and ask where the code list, endpoint rules and pattern descriptions went. If the target cannot carry the GeoPackage schema extension, attach a durable dictionary and validation report. Revalidate target rows, because a correct source constraint cannot prevent truncation, type conversion or label substitution during export.
CHAPTER 9 OF 9 · Test editing and transfer
9. Deliver both the contract and the observed conformance
The handoff names GeoPackage version, schema-extension declaration, user table, stable key, described columns, constraint names and their types. It also states which software layer enforced the rules during the tested edit.
Provide a validation summary: five allowed condition codes, canopy values at both inclusive endpoints and five conforming survey tags. List any exceptions by key and preserve unresolved historical codes without inventing replacements.
Keep labels and codes together. A reader-facing title explains a field; the structural column name keeps queries working; enum descriptions explain individual codes; an authoritative dictionary supplies domain provenance. None of these should silently replace another.
State limits. Constraint conformance does not prove the field observation was accurate. A value 50 can be inside the canopy range and still be measured poorly. The schema answers whether a representation fits declared rules, not whether the real-world claim is true.
The gold standard is a package where the code rules are findable, actual rows are tested, editing behaviour is known and exceptions remain traceable. Another analyst can distinguish a storage success, a schema success and a trustworthy observation.
Practical evidence check
Ask an independent reviewer to reproduce the one invalid enum, the endpoint result and the malformed tag using only the handoff. They should name the responsible source for each rule and distinguish structural conformance from observational truth. If the review can only say the file opens, add the missing row-level evidence before release.
Independent worked case: a clean schema with one invalid row
Use six plots. Five condition codes are 1, 3, 5, 7 and 9. The sixth is 8. All six values fit the INTEGER storage type. Only five belong to the enum habitat_condition.
Give canopy_pct values 0, 20, 40, 60, 80 and 100 under the inclusive range 0–100. All six pass. Change the maximum to exclusive in a test constraint; the row containing 100 now fails without any change to its stored number.
Give survey tags S-2026-001 through S-2026-006. They pass the stated glob pattern. Replace the last with S-26-006; it fails the syntax check. Neither passing form proves that a registry contains the survey.
Insert the invalid enum value through a generic SQLite editor. If it saves, the package demonstrates why declaration and enforcement are different. A post-save validator should report the plot ID, condition_code, value 8 and the enum rule.
Now create a documented exception table or correction workflow rather than changing 8 to 7 by proximity. If an authorised dictionary later maps legacy 8 to a current code, record that crosswalk and source. Until then, unresolved is more truthful than guessed.
Final release test
Validate the final package in two passes. First confirm that the schema-extension tables, declarations and references conform to the applicable GeoPackage contract. Then scan every governed user value against its enum, range or glob rule. A healthy metadata table does not excuse an invalid row, and a clean row set does not repair orphan metadata.
Run the three negative fixtures through each authorised editing path. Keep the observed outcome for invalid enum 8, out-of-range 100.1 and malformed tag S-26-006. If one path silently saves them, require post-save validation or remove that path from the controlled workflow. State where enforcement actually occurs.
Round-trip the allowed boundary values and nulls. Confirm that 0 and 100 retain their intended meaning under the inclusive range, that null remains distinguishable from zero and that text identifiers keep leading characters and case where required. Interface formatting must not conceal storage changes.
Export the code dictionary and exception report with the data when the recipient format cannot carry the schema extension. The report should identify stable keys, original values, violated rules and unresolved status. Do not delete invalid evidence merely to obtain a zero-error summary.
A second reviewer should reproduce every count and explain why a passing constraint does not establish observational accuracy. Release only when the structural field name, reader-facing description, permitted-value rule, enforcement location and observed exceptions can all be traced without private memory.
Check how the receiving interface presents codes. It may substitute labels for values, sort labels alphabetically or hide nulls. Export a small audit view containing stable key, stored value, displayed label and validation result. The view lets a reviewer distinguish a presentation change from a data change and catches duplicated labels that make two codes look identical. Keep the authoritative mapping outside the interface configuration so a saved workspace is not the only copy.
Review the exception policy with the product owner. Decide whether prohibited values block release, enter quarantine or remain with an explicit unresolved flag. The policy must not redefine the enum or range merely to reduce the error count. Record who authorised a crosswalk, which source version it used and whether historical rows were transformed. A later reader should be able to reconstruct both the original code and the released interpretation.
Keep these distinctions visible
| Constraint evidence | What it establishes | What it does not establish |
|---|---|---|
| data-column row | Description and optional constraint link for a real field | That every value has been checked |
| enum | Listed allowed values | Order, distance or arithmetic meaning among codes |
| range | Permitted numeric interval and endpoint inclusion | Measurement unit or observational accuracy |
| glob | Text syntax pattern | Existence or authority of the referenced entity |
| application rejection | Observed enforcement in that workflow | Enforcement by every other writer |
Questions and practical checks
Does SQLite INTEGER enforce an enum?
No. Storage type acceptance is broader than a product code list. Validate against the declared enum or use supported enforcement.
Are schema-extension constraints always enforced automatically?
No. The specification allows enforcement by triggers or application code. Test the actual writer and the saved rows.
Can a range make zero mean missing?
No. Missingness and allowed numeric values are separate decisions. Zero can be valid, prohibited or a code only under an explicit product rule.
Is a glob the same as a regular expression?
No. Use the applicable SQLite GLOB semantics and test known examples rather than copying assumptions from another pattern engine.
Should an unknown code be replaced with the nearest valid code?
Not without an authorised crosswalk. Preserve the original evidence, classify the exception and record any justified transformation.
Continue by the evidence you still need
Check structure and editing scope
Use these when additional schema rules or view definitions may not survive a receiving writer.
GeoPackage extension declarations and safe editing
GeoPackage feature views and stable keys
Check identities and references
Use these when a stable key, structural identifier or GeoPackage system-table relationship can be confused with a display label.
GeoPackage SRS identifiers and geometry-header consistency
GeoPackage structure and translation overview
Check values and missingness
Use these when zero, null, absence or eligibility changes the denominator or record count.
Raster validity masks and coverage denominators
GeoJSON null geometry and record completeness
Sources and scope
The examples follow the schema extension in OGC GeoPackage 1.4 and SQLite’s documented typing and GLOB behaviour. The fictional code list and tags are teaching fixtures, not an official environmental classification.
OGC GeoPackage 1.4 Encoding Standard — Schema extension, data columns and enum, range and glob constraints.
SQLite datatypes — Dynamic typing and column affinity context.
SQLite expression operators — GLOB pattern semantics.
GDAL GeoPackage driver — Current implementation and validation context.
The scenarios and fixture values in this guide are original teaching examples, not reports about a live organisation. Standards and implementation references were checked on 12 November 2026. The checking sequence is educational guidance; it does not certify a particular file, reader or production workflow.
Return to the Gold Standard of Education · Explore How X Works
