forked from FIWARE/context.Orion-LD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitial.sql
69 lines (65 loc) · 1.7 KB
/
initial.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
CREATE TYPE ValueType AS ENUM(
'String',
'Number',
'Boolean',
'Relationship',
'Compound',
'DateTime',
'GeoPoint',
'GeoPolygon',
'GeoMultiPolygon',
'GeoLineString',
'GeoMultiLineString',
'LanguageMap');
CREATE TYPE OperationMode AS ENUM(
'Create',
'Append',
'Update',
'Replace',
'Delete');
CREATE TABLE IF NOT EXISTS entities (
instanceId TEXT PRIMARY KEY,
ts TIMESTAMP NOT NULL,
opMode OperationMode,
id TEXT NOT NULL,
type TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS attributes (
instanceId TEXT PRIMARY KEY,
id TEXT NOT NULL,
opMode OperationMode,
entityId TEXT NOT NULL,
observedAt TIMESTAMP,
subProperties BOOL,
unitCode TEXT,
datasetId TEXT,
valueType ValueType,
text TEXT,
boolean BOOL,
number FLOAT8,
datetime TIMESTAMP,
compound JSONB,
geoPoint GEOGRAPHY(POINTZ, 4326),
geoPolygon GEOGRAPHY(POLYGON, 4326),
geoMultiPolygon GEOGRAPHY(MULTIPOLYGON, 4326),
geoLineString GEOGRAPHY(LINESTRING, 4326),
geoMultiLineString GEOGRAPHY(MULTILINESTRING, 4326),
ts TIMESTAMP NOT NULL);
CREATE TABLE IF NOT EXISTS subAttributes (
instanceId TEXT PRIMARY KEY,
id TEXT NOT NULL,
entityId TEXT NOT NULL,
attrInstanceId TEXT NOT NULL,
observedAt TIMESTAMP,
unitCode TEXT,
valueType ValueType,
text TEXT,
boolean BOOL,
number FLOAT8,
datetime TIMESTAMP,
compound JSONB,
geoPoint GEOGRAPHY(POINTZ, 4326),
geoPolygon GEOGRAPHY(POLYGON, 4326),
geoMultiPolygon GEOGRAPHY(MULTIPOLYGON, 4326),
geoLineString GEOGRAPHY(LINESTRING, 4326),
geoMultiLineString GEOGRAPHY(MULTILINESTRING, 4326),
ts TIMESTAMP NOT NULL);