raster_metadata_table.sql 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. --#############################################################################
  2. -- This SQL script generates the raster metadata table to store
  3. -- and metadata for SQL queries and temporal GIS support.
  4. --
  5. -- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
  6. --#############################################################################
  7. --PRAGMA foreign_keys = ON;
  8. -- The metadata table reflects most of the raster metadata available in grass
  9. CREATE TABLE raster_metadata (
  10. id VARCHAR NOT NULL, -- The id (PFK) is the unique identifier for all tables, it is based on name and mapset (name@mapset) and is used as primary foreign key
  11. strds_register VARCHAR, -- The name of the table storing all space-time raster datasets in which this map is registered
  12. datatype VARCHAR NOT NULL,
  13. cols INTEGER NOT NULL,
  14. rows INTEGER NOT NULL,
  15. number_of_cells INTEGER NOT NULL,
  16. nsres DOUBLE PRECISION NOT NULL,
  17. ewres DOUBLE PRECISION NOT NULL,
  18. min DOUBLE PRECISION,
  19. max DOUBLE PRECISION,
  20. PRIMARY KEY (id),
  21. FOREIGN KEY (id) REFERENCES raster_base (id) ON DELETE CASCADE
  22. );
  23. -- Create a trigger to update the modification time and revision number in case the metadata have been updated
  24. -- Uncommented due to performance issues
  25. --CREATE TRIGGER update_raster_metadata AFTER UPDATE ON raster_metadata
  26. -- BEGIN
  27. -- UPDATE raster_base SET modification_time = datetime("NOW") WHERE id = old.id;
  28. -- UPDATE raster_base SET revision = (revision + 1) WHERE id = old.id;
  29. -- END;