1-- APEX_INSTANCES
 2CREATE TABLE apex_instances (
 3        sensing_time timestamp NOT NULL,
 4        sid_num smallint NOT NULL,
 5        end_time timestamp NOT NULL,
 6        domain varchar(50),
 7        instance varchar(150) NOT NULL,
 8        level varchar(50) NOT NULL,
 9        identifier varchar(150) NOT NULL,
10        procedure varchar(150) NOT NULL,
11        source varchar(150) NOT NULL,
12        parent varchar(150) NOT NULL,
13        attributes jsonb
14);
15ALTER TABLE apex_instances ADD CONSTRAINT apex_instances_pk PRIMARY KEY (sid_num,sensing_time,instance,identifier);
16CREATE INDEX apex_instances_idx1 ON APEX_INSTANCES (SID_NUM,INSTANCE,LEVEL);
17
18-- APEX_LOG
19CREATE TABLE apex_log (
20        sensing_time timestamp NOT NULL,
21        sid_num smallint NOT NULL,
22        instance varchar(50) NOT NULL,
23        domain varchar(50),
24        level varchar(50) NOT NULL,
25        identifier varchar(150),
26        procedure varchar(150) NOT NULL,
27        source varchar(150),
28        parent varchar(150) NOT NULL,
29        attribute varchar(50) NOT NULL,
30        value varchar(2048) NOT NULL,
31        counter bigint CHECK (counter >= 0) NOT NULL
32);
33ALTER TABLE apex_log ADD CONSTRAINT apex_log_idx0 PRIMARY KEY (sid_num,sensing_time,instance,attribute,level,counter);