create new graph definitions (will replace cybergraph)

This commit is contained in:
Helmut Merz 2021-02-14 11:01:58 +01:00
parent d1022c0212
commit ac494db49d
3 changed files with 51 additions and 0 deletions

4
pgsql/graph/drop.sql Normal file
View file

@ -0,0 +1,4 @@
-- storage-common/qgsql/graph/drop.sql
drop table steps;
drop sequence steps_id_seq;

View file

@ -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"

23
pgsql/graph/tables.sql Normal file
View file

@ -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);