23 lines
943 B
SQL
23 lines
943 B
SQL
-- storage-common/qgsql/graph/tables.sql
|
|
-- a simple generic RDF-like graph storage using only one tabel
|
|
|
|
create sequence steps_id_seq start with 21;
|
|
-- note: bootstrap rows (concepts) get explicit IDs
|
|
|
|
create table steps (
|
|
id bigint not null primary key default nextval('steps_id_seq'),
|
|
item bigint not null, --references steps,
|
|
property bigint not null, --references steps,
|
|
valtype smallint not null check (valtype in (0, 1, 2, 3)),
|
|
-- 0 = Nothing, 1 = Text, 2 = Number, 3 = Step
|
|
numval bigint, -- null except for valtype 2 and 3
|
|
textval text -- null except for valtype 1
|
|
);
|
|
|
|
-- indexes
|
|
|
|
create index idx_ipv on steps USING btree (item, property, valtype, numval, textval);
|
|
create index idx_pv on steps using btree (property, valtype, numval, textval);
|
|
|
|
-- optional, not used (values make only sense together with a property):
|
|
--create index idx_vi on steps using btree (valtype, numval, strval, item);
|