map_tables_template.sql 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --#############################################################################
  2. -- This SQL script generates the grass map tables to store time stamps, revision
  3. -- and spatial extent for SQL queries and temporal GIS support.
  4. -- Additionally several triggers are created for convenient functions
  5. -- The grass map metadata is map specific (raster, raster3d and vector maps are
  6. -- supported)
  7. --
  8. -- The placeholder GRASS_MAP will be replaced by raster, raster3d and vector
  9. --
  10. -- Author: Soeren Gebbert soerengebbert <at> googlemail <dot> com
  11. --#############################################################################
  12. -- GRASS_MAP is a placeholder for specific map type: raster, raster3d or vector
  13. CREATE TABLE GRASS_MAP_base (
  14. id VARCHAR NOT NULL, -- The id (PK) is the unique identifier for all tables, it is based on name (layer) and mapset (name(:layer)@mapset) and is used as primary key
  15. name VARCHAR NOT NULL, -- name of the grass map
  16. mapset VARCHAR NOT NULL, -- mapset of the grass map
  17. layer VARCHAR, -- The layer id of the map, this is currently only in use by vector maps
  18. creator VARCHAR NOT NULL,
  19. temporal_type VARCHAR, -- The temporal type of the grass map "absolute" or "relative" or NULL in case no time stamp is available
  20. creation_time TIMESTAMP NOT NULL, -- The time of creation of the grass map
  21. PRIMARY KEY (id)
  22. );
  23. -- Relative valid time interval with start and end time
  24. CREATE TABLE GRASS_MAP_relative_time (
  25. id VARCHAR NOT NULL, -- The id (PK) is the unique identifier for all tables, it is based on name and mapset (name@mapset) and is used as primary foreign key
  26. start_time INTEGER, -- The relative valid start time in
  27. end_time INTEGER, -- The relative valid end time in
  28. unit VARCHAR, -- The relative time unit, available are "years, months, days, minutes, seconds"
  29. PRIMARY KEY (id)
  30. );
  31. CREATE TABLE GRASS_MAP_absolute_time (
  32. id VARCHAR NOT NULL, -- The id (PK) is the unique identifier for all tables, it is based on name and mapset (name@mapset) and is used as primary key
  33. start_time TIMESTAMP, -- Start of the valid time, can be NULL if no time information is available
  34. end_time TIMESTAMP, -- End of the valid time, can be NULL if no time information is available or valid time is a single point in time
  35. PRIMARY KEY (id)
  36. );
  37. -- The spatial extent of a raster map
  38. CREATE TABLE GRASS_MAP_spatial_extent (
  39. id VARCHAR NOT NULL, -- The id (PK) is the unique identifier for all tables, it is based on name and mapset (name@mapset) and is used as primary key
  40. -- below is the spatial extent of the map
  41. north DOUBLE PRECISION NOT NULL,
  42. south DOUBLE PRECISION NOT NULL,
  43. east DOUBLE PRECISION NOT NULL,
  44. west DOUBLE PRECISION NOT NULL,
  45. top DOUBLE PRECISION NOT NULL,
  46. bottom DOUBLE PRECISION NOT NULL,
  47. proj VARCHAR,
  48. PRIMARY KEY (id)
  49. );
  50. -- We have a specific table that stores the space time dataset ids in which the maps a registered
  51. CREATE TABLE GRASS_MAP_stds_register (
  52. id VARCHAR NOT NULL, -- The id (PK) is the unique identifier for all tables, it is based on name (layer) and mapset (name(:layer)@mapset) and is used as primary key
  53. registered_stds VARCHAR, -- This column stores the names of all space time datasets in which a specific map is registered
  54. PRIMARY KEY (id)
  55. );