From ac494db49d028ce53590755eb0e564f0f133445c Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sun, 14 Feb 2021 11:01:58 +0100 Subject: [PATCH] create new graph definitions (will replace cybergraph) --- pgsql/graph/drop.sql | 4 ++++ pgsql/graph/load_basic.sql | 24 ++++++++++++++++++++++++ pgsql/graph/tables.sql | 23 +++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 pgsql/graph/drop.sql create mode 100644 pgsql/graph/load_basic.sql create mode 100644 pgsql/graph/tables.sql diff --git a/pgsql/graph/drop.sql b/pgsql/graph/drop.sql new file mode 100644 index 0000000..10375f0 --- /dev/null +++ b/pgsql/graph/drop.sql @@ -0,0 +1,4 @@ +-- storage-common/qgsql/graph/drop.sql + +drop table steps; +drop sequence steps_id_seq; diff --git a/pgsql/graph/load_basic.sql b/pgsql/graph/load_basic.sql new file mode 100644 index 0000000..d9aec35 --- /dev/null +++ b/pgsql/graph/load_basic.sql @@ -0,0 +1,24 @@ +-- storage-common/qgsql/graph/load_basic.sql +-- load bootstrap and basic semantic steps + +-- basic concepts with fixed IDs +insert into steps (id, item, property, valtype, numval, strval) values + (1, 1, 2, 3, 1, null), -- this: this is this + (2, 1, 2, 3, 2, null), -- is: this is is + (3, 1, 2, 3, 3, null), -- Class: this is Class + (4, 1, 2, 3, 4, null), -- type: this is type + (5, 1, 2, 3, 5, null), -- Property: this is Property + (6, 1, 2, 3, 6, null); -- name: this is name + +-- basic types and names +insert into steps (item, property, valtype, numval, strval) values + (3, 4, 3, 3, null), -- Class type Class + (5, 4, 3, 3, null), -- property type Class + (4, 4, 3, 5, null), -- type type Property + (6, 4, 3, 5, null), -- name type Property + (1, 6, 1, null, 'this'), -- this name "this" + (2, 6, 1, null, 'is'), -- is name "is" + (4, 6, 1, null, 'type'), -- type name "type" + (3, 6, 1, null, 'Class'), -- Class name "Class" + (5, 6, 1, null, 'Property'), -- Property name "Property" + (6, 6, 1, null, 'name'); -- name name "name" diff --git a/pgsql/graph/tables.sql b/pgsql/graph/tables.sql new file mode 100644 index 0000000..0b536d7 --- /dev/null +++ b/pgsql/graph/tables.sql @@ -0,0 +1,23 @@ +-- storage-common/qgsql/graph/tables.sql +-- a simple generic RDF-like graph storage using only one tabel + +create sequence steps_id_seq start with 11; +-- note: bootstrap rows get explicit IDs + +create table steps ( + id bigint not null primary key default nextval('steps_id_seq'), + item bigint not null, + 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 + strval text -- null except for valtype 1 +); + +-- indexes + +create index idx_ipv on steps USING btree (item, property, valtype, numval, strval); +create index idx_pv on steps using btree (property, valtype, numval, strval); + +-- optional, not used (values make only sense together with a property): +--create index idx_vi on steps using btree (valtype, numval, strval, item);