diff --git a/examples/cities/pgsql/fload.sql b/examples/cities/pgsql/fload.sql index 17839e3..34b7a88 100644 --- a/examples/cities/pgsql/fload.sql +++ b/examples/cities/pgsql/fload.sql @@ -6,33 +6,23 @@ declare count int := 0; event bigint := new_event(); city record; - rkey text; + key text; begin for city in select name, regiokey, ckey, inhabitants from cities where rectype = '60' --limit 1 loop - rkey := load_city(city.name, city.regiokey, city.ckey, city.inhabitants, event); + key := 'xcd:' || city.regiokey; + insert into vtriples (stname, stext, ptext, otname, otext, creation) values + ('node', key, 'rdf:type', 'node', 'xc:City', event), + ('node', key, 'rdfs:label', 'text', city.name, event), + ('node', key, 'xc:regiokey', 'text', city.regiokey, event), + ('node', key, 'xc:ckey', 'text', city.ckey, event), + ('node', key, 'xc:population', 'int', text(city.inhabitants), event); count := count + 1; end loop; return count; end; $$ language plpgsql; - -create or replace function load_city( - name text, regiokey text, ckey text, inhabitants int, - event bigint) returns text as $$ -declare - key text := 'xcd:' || regiokey; -begin - insert into vtriples (stname, stext, ptext, otname, otext, creation) values - ('node', key, 'rdf:type', 'node', 'xc:City', event), - ('node', key, 'rdfs:label', 'text', name, event), - ('node', key, 'xc:regiokey', 'text', regiokey, event), - ('node', key, 'xc:ckey', 'text', ckey, event), - ('node', key, 'xc:population', 'int', text(inhabitants), event); - return regiokey; -end; -$$ language plpgsql; diff --git a/examples/cities/pgsql/lmeta.sql b/examples/cities/pgsql/lmeta.sql index 80ed464..750a31f 100644 --- a/examples/cities/pgsql/lmeta.sql +++ b/examples/cities/pgsql/lmeta.sql @@ -2,7 +2,7 @@ -- load metadata triples for cities example project select load_namespace('http://cyberconcepts.org/cco-example/cities#', 'xc'); -select load_namespace('http://cyberconcepts.org/cco-example/cities_data#', 'xcd'); +select load_namespace('http://cyberconcepts.org/cco-example/cities-data#', 'xcd'); select new_event() as event \gset diff --git a/pgsql/init.sql b/pgsql/init.sql index 1dff721..b0e03a9 100644 --- a/pgsql/init.sql +++ b/pgsql/init.sql @@ -1,14 +1,12 @@ -- create tables and views \i tcreate.sql +\i fshow.sql \i vtriples.sql --- create functions +-- create loading function and triggers \i fload.sql -\i fshow.sql - --- create triggers -\i tgtriple.sql +\i tgtriples.sql -- load data \i lbase.sql diff --git a/pgsql/tcreate.sql b/pgsql/tcreate.sql index 737214a..b231f14 100644 --- a/pgsql/tcreate.sql +++ b/pgsql/tcreate.sql @@ -42,15 +42,6 @@ CREATE TABLE texts ( text text NOT NULL unique ); --- set table owner - -ALTER TABLE nodes OWNER TO cco; -ALTER TABLE datatypes OWNER TO cco; -ALTER TABLE namespaces OWNER TO cco; -ALTER TABLE triples OWNER TO cco; -ALTER TABLE events OWNER TO cco; -ALTER TABLE texts OWNER TO cco; - -- indexes CREATE INDEX idx_iri ON namespaces USING btree (iri);