Document A0cd6168e9408c9c095f700d7c6ec3224

Author Adc5dd0c30f6e63932811ed60e019bb2d
Date Created Sun, 14 Jul 2013 17:44:18 +0200
Last Modified Wed, 14 Mar 2018 20:52:59 +0100
Version 2556
Contract Ab6e300959b7c33de0b2d34238f56c906
Protection /Adc5dd0c30f6e63932811ed60e019bb2d /A8334f0c029a3088e3b04e90abb1ac3a3
Content Type text/xml
Size Body: 419 SQL: 2072576

edit - bail - links - rights - support

Check

Equivalent S-Expression

(sql-query "select * from sqlite_master")

Result

Literal

#(#(type name tbl_name rootpage sql) #(table table_info table_info 3 CREATE TABLE table_info
  (name text unique, sys boolean default 0, description text
  ,deleteable boolean default 0 -- offer delete button
  )) #(index sqlite_autoindex_table_info_1 table_info 4 #f) #(table table_column_types table_column_types 5 CREATE TABLE table_column_types
  (name text, column text, dn text default column,
   edit text default 'textline', ro text default 'td',
   unique(name,column)
  )) #(index sqlite_autoindex_table_column_types_1 table_column_types 6 #f) #(table state state 7 CREATE TABLE state (s integer primary key on conflict replace, name text unique)) #(index sqlite_autoindex_state_1 state 8 #f) #(table service service 9 CREATE TABLE service (s integer, a text, t text, unique (s,a))) #(index sqlite_autoindex_service_1 service 10 #f) #(table client client 11 CREATE TABLE client (s integer, a text, t text, unique (s,a))) #(index sqlite_autoindex_client_1 client 12 #f) #(table views views 13 CREATE TABLE views(id integer primary key autoincrement
  ,name text unique
  ,t text, arguments text, description text
  ,unique(t,arguments)
  )) #(index sqlite_autoindex_views_1 views 14 #f) #(index sqlite_autoindex_views_2 views 15 #f) #(table sqlite_sequence sqlite_sequence 16 CREATE TABLE sqlite_sequence(name,seq)) #(index views_by_name views 17 CREATE INDEX views_by_name on views(t)) #(trigger views_protect_internal views 0 CREATE TRIGGER views_protect_internal before delete on views for each row
  when old.arguments is null
  begin
   select raise(abort,'will not delete predefined views');
  end) #(trigger views_protect_internal_up views 0 CREATE TRIGGER views_protect_internal_up before update on views for each row
  when old.arguments is null
  begin
   select raise(abort,'will not modify predefined views');
  end) #(table view_templates view_templates 18 CREATE TABLE view_templates(name text unique)) #(index sqlite_autoindex_view_templates_1 view_templates 19 #f) #(table intern intern 20 CREATE TABLE intern (s integer, n text, v text references views(name), unique (s,n))) #(index sqlite_autoindex_intern_1 intern 21 #f) #(index intern_n intern 22 CREATE INDEX intern_n on intern(n)) #(table extern extern 23 CREATE TABLE extern (s integer, n text, v text references views(name), unique (s,n))) #(index sqlite_autoindex_extern_1 extern 24 #f) #(index extern_n extern 25 CREATE INDEX extern_n on extern(n)) #(table language language 26 CREATE TABLE language(id integer primary key autoincrement, code text, base integer)) #(table l10n l10n 27 CREATE TABLE l10n (orig text unique, display text not null, unique(orig,display))) #(index sqlite_autoindex_l10n_1 l10n 28 #f) #(index sqlite_autoindex_l10n_2 l10n 29 #f) #(index l10n_orig l10n 30 CREATE INDEX l10n_orig on l10n(orig)) #(index l10n_display l10n 31 CREATE INDEX l10n_display on l10n(display)) #(table menue menue 32 CREATE TABLE menue (angle double not null, radius double default 1
  ,label text not null, help text, view text not null)) #(index menue_angle menue 33 CREATE INDEX menue_angle on menue(angle)) #(index menue_radius menue 34 CREATE INDEX menue_radius on menue(radius)) #(index menue_view menue 35 CREATE INDEX menue_view on menue(view)) #(view menue_intern menue_intern 0 CREATE VIEW menue_intern as select angle, radius, label, help, view, s
  from menue join intern on menue.view = intern.n) #(view menue_extern menue_extern 0 CREATE VIEW menue_extern as select angle, radius, label, help, view, s
  from menue join extern on menue.view = extern.n) #(table storage_class storage_class 36 CREATE TABLE storage_class(id integer primary key, comment text)) #(table literal literal 37 CREATE TABLE literal(id integer primary key autoincrement
  ,s integer references rdfnode(id) deferrable
  ,cls integer default 0 references storage_class(id)
  ,v text
  ,language integer default 0 references language(id)
 )) #(index literal_v literal 38 CREATE UNIQUE INDEX literal_v on literal(v,id,s,cls)) #(index literal_s literal 39 CREATE UNIQUE INDEX literal_s on literal(s,id,cls)) #(index literal_cls literal 40 CREATE INDEX literal_cls on literal(cls,id,s)) #(view literal_next literal_next 0 CREATE VIEW literal_next as select max(id)+1 as id, s, cls, v, language from literal) #(trigger literal_next_id literal_next 0 CREATE TRIGGER literal_next_id instead of insert on literal_next for each row
  begin
   insert into literal(id,s,cls,v,language)
    select id, new.s, coalesce(new.cls,0), new.v, new.language from literal_next;
  end) #(table anywhere anywhere 0 CREATE VIRTUAL TABLE anywhere using fts4()) #(table anywhere_content anywhere_content 41 CREATE TABLE 'anywhere_content'(docid INTEGER PRIMARY KEY, 'c0content')) #(table anywhere_segments anywhere_segments 42 CREATE TABLE 'anywhere_segments'(blockid INTEGER PRIMARY KEY, block BLOB)) #(table anywhere_segdir anywhere_segdir 43 CREATE TABLE 'anywhere_segdir'(level INTEGER,idx INTEGER,start_block INTEGER,leaves_end_block INTEGER,end_block INTEGER,root BLOB,PRIMARY KEY(level, idx))) #(index sqlite_autoindex_anywhere_segdir_1 anywhere_segdir 44 #f) #(table anywhere_docsize anywhere_docsize 45 CREATE TABLE 'anywhere_docsize'(docid INTEGER PRIMARY KEY, size BLOB)) #(table anywhere_stat anywhere_stat 46 CREATE TABLE 'anywhere_stat'(id INTEGER PRIMARY KEY, value BLOB)) #(view preview_anywhere preview_anywhere 0 CREATE VIEW preview_anywhere as
  select s, v, substr(coalesce(content,v), 1, 200) as content from
   literal left join anywhere on literal.id = anywhere.docid) #(table attic_literal attic_literal 47 CREATE TABLE attic_literal(id integer primary key, s integer, v text, unique(id,s,v))) #(index sqlite_autoindex_attic_literal_1 attic_literal 48 #f) #(trigger delete_on_literal4log literal 0 CREATE TRIGGER delete_on_literal4log after delete on literal
  when old.cls = 10
  begin
   insert into attic_literal select old.id, old.s, old.v;
  end) #(table rdfnode rdfnode 49 CREATE TABLE rdfnode (id integer primary key autoincrement
  ,s integer not null default id references rdfnode(id) deferrable initially deferred
  ,p integer not null references rdfnode(id) deferrable initially deferred
  ,o integer not null references rdfnode(id) deferrable initially deferred
  ,unique(s,p,o)
 )) #(index sqlite_autoindex_rdfnode_1 rdfnode 50 #f) #(index rdfnode_s_poi rdfnode 51 CREATE INDEX rdfnode_s_poi on rdfnode(s,p,o,id)) #(index rdfnode_p_soi rdfnode 52 CREATE INDEX rdfnode_p_soi on rdfnode(p,s,o,id)) #(index rdfnode_o_spi rdfnode 53 CREATE INDEX rdfnode_o_spi on rdfnode(o,s,p,id)) #(trigger guard_rdfnode_types rdfnode 0 CREATE TRIGGER guard_rdfnode_types before insert on rdfnode for each row
  begin
   select case when typeof(new.s) != 'integer' then raise(abort,'rdf subject not integer') end;
   select case when typeof(new.p) != 'integer' then raise(abort,'rdf predicate not integer') end;
   select case when typeof(new.o) != 'integer' then raise(abort,'rdf object not integer') end;
  end) #(view literal_is_used literal_is_used 0 CREATE VIEW literal_is_used as
   select l.id as lid, l.s as s, t.id as nid from rdfnode as t join literal as l
   on (l.s = t.s and t.s != t.id) or l.s = t.p or l.s = t.o) #(trigger delete_on_literal literal 0 CREATE TRIGGER delete_on_literal before delete on literal for each row
  begin
   select raise(abort, 'literal is still used')
   from literal_is_used as used where used.lid = old.id;
  end) #(trigger delete_on_literal_anywhere_too literal 0 CREATE TRIGGER delete_on_literal_anywhere_too after delete on literal for each row
  begin
   delete from anywhere where docid = old.s;
  end) #(view literal_still_used literal_still_used 0 CREATE VIEW literal_still_used as
  select lid, u.s as r, nid, t.s as s, t.p as p, t.o as o
  from literal_is_used as u
  join rdfnode as d on d.id = u.s  and d.id != nid
  join rdfnode as t on t.id != t.s and t.id != nid) #(view l4r l4r 0 CREATE VIEW l4r as
  select t.id as s, coalesce(lo.v, t.id) as v
  from rdfnode as t
  join literal as lo on lo.s = t.id) #(view rdflit rdflit 0 CREATE VIEW rdflit as
  select ls.v as s, lp.v as p, lo.v as o
  from rdfnode as t
  join l4r as ls on ls.s = t.s
  join l4r as lp on lp.s = t.p
  join l4r as lo on lo.s = t.o) #(trigger insert_on_rdflit rdflit 0 CREATE TRIGGER insert_on_rdflit instead of insert on rdflit for each row
  begin
   insert into rdfnode(s,p,o)
    select
     (select s from l4r where v = new.s) as s,
     (select s from l4r where v = new.p) as p,
     (select s from l4r where v = new.o) as o;
  end) #(table attachment attachment 54 CREATE TABLE attachment(id integer primary key autoincrement
  ,s integer references rdfnode(id)
  ,oid text not NULL
  ,title text default ''
  ,unique (s,oid)
  )) #(index sqlite_autoindex_attachment_1 attachment 55 #f) #(trigger attachment2rdfnode attachment 0 CREATE TRIGGER attachment2rdfnode after insert on attachment for each row
  begin
   insert into rdfnode(s,p,o) values(0,1,1);
   update rdfnode set s = last_insert_rowid(), o = 0 where _rowid_ = last_insert_rowid();
   update attachment set s = last_insert_rowid() where new.id = id;
  end) #(trigger attachment00 attachment 0 CREATE TRIGGER attachment00 before delete on attachment for each row
  begin
   delete from rdfnode where s = old.s or p = old.s or o = old.s;
  end) #(view literal4resource literal4resource 0 CREATE VIEW literal4resource as
  select t.id as s, coalesce(l10n.display,l.v, t.s || '⊥') as display
  from rdfnode as t
  join literal as l on l.s = t.id
  left join l10n on l10n.orig=l.v) #(view literal44resource literal44resource 0 CREATE VIEW literal44resource as
  select t.id as id,
   case
   when literal.id then (select display from literal4resource where s = t.id)
   when t.id = t.s then (select display from literal4resource where s = t.s)
   else
    coalesce((select display from literal4resource where s = t.id),
             (select display from literal4resource where s = t.s) || '↗',
             '↗' || t.s)
    || ' '
    || (select coalesce(l10n.display,dflt) as display
        from (select 'has' as dflt) left join l10n on orig = 'has:')
    || ' '
    || (select display from literal4resource where s = t.p)
    || ' '
    || (select coalesce(l10n.display,dflt) as display
        from (select 'as' as dflt) left join l10n on orig = 'as:')
    || ' '
    || (select display from literal4resource where s = t.o)
    || '.'
   end as display
    from rdfnode as t left join literal on literal.s = t.id) #(view literal_isDefinedBy literal_isDefinedBy 0 CREATE VIEW literal_isDefinedBy as select s,o from rdflit
  where p = 'http://www.w3.org/2000/01/rdf-schema#isDefinedBy') #(trigger insert_on_literal_isDefinedBy literal_isDefinedBy 0 CREATE TRIGGER insert_on_literal_isDefinedBy
  instead of insert on literal_isDefinedBy for each row
  begin
   insert into rdflit(s,p,o)
    select new.s,'http://www.w3.org/2000/01/rdf-schema#isDefinedBy',new.o;
  end) #(view literal_v_de literal_v_de 0 CREATE VIEW literal_v_de as select literal.id, literal.v
  from literal join language on literal.language = language.id
  where literal.v is not null) #(trigger literal2intern_de literal_v_de 0 CREATE TRIGGER literal2intern_de instead of insert on literal_v_de for each row
  when not exists (select * from literal where v = new.v)
  begin
   insert into literal_next(v,language) select new.v, id from language where code = 'de';
  end) #(view literal_v_dflt literal_v_dflt 0 CREATE VIEW literal_v_dflt as select literal.id, literal.v
  from literal join language on literal.language = language.id
  where literal.v is not null) #(trigger literal2intern_dflt literal_v_dflt 0 CREATE TRIGGER literal2intern_dflt instead of insert on literal_v_dflt for each row
  when not exists (select * from literal where v = new.v)
  begin
   insert into literal_next(v,language) select new.v, id from language where code = 'en';
  end) #(view spo_o_literal spo_o_literal 0 CREATE VIEW spo_o_literal as select t.s, t.p, literal.v as o
  from rdfnode as t
  join literal on t.id = literal.s
  where not literal.v is null) #(view spo_deleteable spo_deleteable 0 CREATE VIEW spo_deleteable as select id, id as rowid from rdfnode) #(view rdf_is_used rdf_is_used 0 CREATE VIEW rdf_is_used as select
  t.id as keep, del.id as del
  from rdfnode as t join rdfnode as del
  on del.id != t.id and del.id = t.s or del.id = t.p or del.id=t.o) #(trigger delete_on_spo_deleteable spo_deleteable 0 CREATE TRIGGER delete_on_spo_deleteable instead of delete on spo_deleteable for each row
  when not exists (select keep from rdf_is_used where del = old.rowid)
  begin
   delete from rdfnode where id = old.rowid;
   delete from literal where s = old.rowid;
  end) #(trigger insert_on_spo_o_literal_de spo_o_literal 0 CREATE TRIGGER insert_on_spo_o_literal_de instead of insert on spo_o_literal for each row
  begin
   insert into literal_v_de(v) select new.o;
   insert into rdfnode(s,p,o) select new.s, new.p, l.s from literal as l where l.v = new.o;
  end) #(view rdf_definition rdf_definition 0 CREATE VIEW rdf_definition as  select t.s as s, literal.s as p, t.o from rdfnode as t
  join literal on literal.s = t.p and literal.v = 'http://www.w3.org/2000/01/rdf-schema#isDefinedBy') #(trigger insert_on_rdf_definition rdf_definition 0 CREATE TRIGGER insert_on_rdf_definition
  instead of insert on rdf_definition for each row
  begin
   insert into literal_v_de(v) select new.s;
   insert into rdfnode(s,p,o)
    select l.s, def.s, new.o from literal as l
    join literal as def on def.v = 'http://www.w3.org/2000/01/rdf-schema#isDefinedBy'
    where l.v = new.s;
  end) #(view rdf_new_s_literal rdf_new_s_literal 0 CREATE VIEW rdf_new_s_literal as select *
  from rdfnode as t join literal on literal.s = t.id) #(trigger insert_on_rdf_new_s_literal rdf_new_s_literal 0 CREATE TRIGGER insert_on_rdf_new_s_literal
  instead of insert on rdf_new_s_literal for each row
  begin
   insert into literal_next(s,cls,v,language) select new.s, coalesce(new.cls,0), new.v, new.language;
   insert into rdfnode(s,p,o) select l.s, new.p, new.o from literal as l
    where l.id = (select max(id) from literal);
  end) #(view rdf_subClassOf rdf_subClassOf 0 CREATE VIEW rdf_subClassOf as select t.s as s, t.o as o from rdfnode as t
  join literal on t.p = literal.s and literal.v = 'http://www.w3.org/2000/01/rdf-schema#subClassOf'
  --  where p=...) #(view rdf_subPropertyOf rdf_subPropertyOf 0 CREATE VIEW rdf_subPropertyOf as select t.s as s, t.o as o from rdfnode as t
  join literal on t.p = literal.s and literal.v = 'http://www.w3.org/2000/01/rdf-schema#subPropertyOf') #(view literal_subClassOf literal_subClassOf 0 CREATE VIEW literal_subClassOf as select s,o from rdflit
  where p = 'http://www.w3.org/2000/01/rdf-schema#subClassOf') #(trigger insert_on_literal_subClassOf literal_subClassOf 0 CREATE TRIGGER insert_on_literal_subClassOf
  instead of insert on literal_subClassOf for each row
  begin
   insert into rdflit(s,p,o)
    select new.s,'http://www.w3.org/2000/01/rdf-schema#subClassOf',new.o;
  end) #(view literal_subPropertyOf literal_subPropertyOf 0 CREATE VIEW literal_subPropertyOf as select s,o from rdflit
  where p = 'http://www.w3.org/2000/01/rdf-schema#subPropertyOf') #(trigger insert_on_literal_subPropertyOf literal_subPropertyOf 0 CREATE TRIGGER insert_on_literal_subPropertyOf
  instead of insert on literal_subPropertyOf for each row
  begin
   insert into rdflit(s,p,o)
    select new.s,'http://www.w3.org/2000/01/rdf-schema#subPropertyOf',new.o;
  end) #(view rdf_type rdf_type 0 CREATE VIEW rdf_type as select t.id as id, t.s as s, o from rdfnode as t
  join literal on t.p = literal.s and literal.v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type') #(view rdf_p_literal rdf_p_literal 0 CREATE VIEW rdf_p_literal as select *
  from rdfnode join literal on literal.s = rdfnode.p) #(table rdf_type_all_resources rdf_type_all_resources 56 CREATE TABLE rdf_type_all_resources(
  s integer not null references rdfnode(id),
  o integer not null references rdfnode(id))) #(index rdf_type_all_resources_s rdf_type_all_resources 57 CREATE INDEX rdf_type_all_resources_s on rdf_type_all_resources(s,o)) #(index rdf_type_all_resources_o rdf_type_all_resources 58 CREATE INDEX rdf_type_all_resources_o on rdf_type_all_resources(o,s)) #(trigger insert_on_rdf_type2all rdfnode 0 CREATE TRIGGER insert_on_rdf_type2all after insert on rdfnode for each row
  when new.p = (select s from literal where v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
  begin
   insert into rdf_type_all_resources select new.s, new.o;
  end) #(trigger insert_on_rdf_r2all rdfnode 0 CREATE TRIGGER insert_on_rdf_r2all after insert on rdfnode for each row
  begin
   insert into rdf_type_all_resources
    select new.id, literal.s from literal where v = 'http://www.w3.org/2000/01/rdf-schema#Resource';
  end) #(trigger delete_on_rdf_all2r rdfnode 0 CREATE TRIGGER delete_on_rdf_all2r after delete on rdfnode for each row
  when old.p = (select s from literal where v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
  begin
   delete from rdf_type_all_resources where s = old.s and o = old.o;
  end) #(trigger delete_on_rdf_all2 rdfnode 0 CREATE TRIGGER delete_on_rdf_all2 after delete on rdfnode for each row
  begin
   delete from rdf_type_all_resources where s = old.id;
  end) #(view literal_type literal_type 0 CREATE VIEW literal_type as select s,o from rdflit
  where p = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type') #(trigger insert_on_literal_type literal_type 0 CREATE TRIGGER insert_on_literal_type
  instead of insert on literal_type for each row
  begin
   insert into rdflit(s,p,o)
    select new.s,
     'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
     new.o;
  end) #(view rdf_property rdf_property 0 CREATE VIEW rdf_property as select s from rdfnode
  where p = (select s from literal where v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
  and o = (select s from literal where v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property')) #(view literal_property literal_property 0 CREATE VIEW literal_property as select v from literal join rdf_property as p on literal.s=p.s) #(view defined_definitions defined_definitions 0 CREATE VIEW defined_definitions as select * from rdf_type) #(trigger insert_on_defined_definitions defined_definitions 0 CREATE TRIGGER insert_on_defined_definitions
  instead of insert on defined_definitions for each row
  begin
   insert into literal_v_de(v) select new.s;
   insert into rdfnode(s,p,o)
    select l.s, lp.s, new.o from literal as l join literal as lp
     on l.v = new.s and lp.v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
  end) #(view rdf_tc_hook rdf_tc_hook 0 CREATE VIEW rdf_tc_hook as select * from rdfnode) #(view rdf_transitive_p rdf_transitive_p 0 CREATE VIEW rdf_transitive_p as select t.s as p from rdfnode as t
 join rdf_property on t.s = rdf_property.s
  and t.p = 2 and t.o = t.s) #(table rdf_tc rdf_tc 59 CREATE TABLE rdf_tc (
  s integer not null references rdfnode(id)
  ,p integer not null references rdfnode(id)
  ,o integer not null references rdfnode(id)
  ,unique(s,p,o)
 )) #(index sqlite_autoindex_rdf_tc_1 rdf_tc 60 #f) #(index rdf_tc_s_po rdf_tc 61 CREATE INDEX rdf_tc_s_po on rdf_tc(s,p,o)) #(index rdf_tc_p_so rdf_tc 62 CREATE INDEX rdf_tc_p_so on rdf_tc(p,s,o)) #(index rdf_tc_o_sp rdf_tc 63 CREATE INDEX rdf_tc_o_sp on rdf_tc(o,s,p)) #(table rdf_tc_new rdf_tc_new 64 CREATE TABLE rdf_tc_new (s integer, o integer)) #(index rdf_tc_new_s_o rdf_tc_new 65 CREATE INDEX rdf_tc_new_s_o on rdf_tc_new(s,o)) #(table rdf_tc_delta rdf_tc_delta 66 CREATE TABLE rdf_tc_delta (s integer, o integer)) #(index rdf_tc_delta_s_o rdf_tc_delta 67 CREATE INDEX rdf_tc_delta_s_o on rdf_tc_delta(s,o)) #(table rdf_tc_suspect rdf_tc_suspect 68 CREATE TABLE rdf_tc_suspect (s integer, o integer)) #(index rdf_tc_suspect_s_o rdf_tc_suspect 69 CREATE INDEX rdf_tc_suspect_s_o on rdf_tc_suspect(s,o)) #(trigger insert_on_rdf_2tc rdf_tc_hook 0 CREATE TRIGGER insert_on_rdf_2tc instead of insert on rdf_tc_hook for each row
  when exists (select * from rdf_transitive_p where p = new.p)
  begin
   insert into rdf_tc_new select * from
    (select s, new.o as o from rdf_tc where rdf_tc.o = new.s and rdf_tc.p = new.p
     union
     select new.s as s, o from rdf_tc where new.o = rdf_tc.s and rdf_tc.p = new.p
     union
     select tc1.s as s, tc2.o as o
     from rdf_tc as tc1 join rdf_tc as tc2 on tc1.p = tc2.p = new.p
     where tc1.o = new.s and tc2.s = new.o
    );
   insert into rdf_tc_new(s,o) values (new.s, new.o);
   insert into rdf_tc_delta
    select * from rdf_tc_new as tn
    where not exists
     (select * from rdf_tc where rdf_tc.s = tn.s and rdf_tc.o=tn.o and rdf_tc.p = new.p);
   insert into rdf_tc select s, new.p, o from rdf_tc_delta;
   delete from rdf_tc_new;
   delete from rdf_tc_delta;
  end) #(trigger delete_from_rdf_2tc rdf_tc_hook 0 CREATE TRIGGER delete_from_rdf_2tc instead of delete on rdf_tc_hook for each row
  when exists (select * from rdf_transitive_p where p = old.p)
  begin
   insert into rdf_tc_suspect(s,o)
    select x.s, y.o
     from rdf_tc as x join rdf_tc as y
     where x.o = old.s and y.s = old.o
    union
     select x.s, old.o from rdf_tc as x where x.o = old.s  and x.p = old.p
    union
     select old.s, x.o from rdf_tc as x where x.s = old.o  and x.p = old.p
    union
     select x.s, x.o from rdf_tc as x
     where x.s = old.s and x.o = old.o
      and x.p = old.p;
   insert into rdf_tc_delta(s,o)
    select s,o from rdf_tc as tc where tc.p = old.p
     and not exists
     (select * from rdf_tc_suspect as sus where sus.s = tc.s and sus.o = tc.o)
    union
    select s,o from rdf_tc_hook as g where g.p = old.p and g.s != old.s and g.o != old.o;
   delete from rdf_tc_suspect;
   insert into rdf_tc_new
    select * from rdf_tc_delta
    union
    select t1.s, t2.o
     from rdf_tc_delta t1, rdf_tc_delta t2
     where t1.o = t2.s
    union
    select t1.s, t3.o
     from rdf_tc_delta t1, rdf_tc_delta t2, rdf_tc_delta t3
     where t1.o = t2.s and t2.o = t3.s;
   delete from rdf_tc
     where p = old.p and not exists
      (select * from rdf_tc_new as tn where tn.s = rdf_tc.s and tn.o = rdf_tc.o);
   delete from rdf_tc_delta;
   delete from rdf_tc_new;
  end) #(trigger insert_on_rdfnode2tc rdfnode 0 CREATE TRIGGER insert_on_rdfnode2tc after insert on rdfnode for each row
  begin
   insert into rdf_tc_hook(s,p,o) values(new.s, new.p, new.o);
  end) #(trigger delete_from_rdfnode2tc rdfnode 0 CREATE TRIGGER delete_from_rdfnode2tc before delete on rdfnode for each row
  begin
   delete from rdf_tc_hook where s = old.s and o = old.o and p = old.p;
  end) #(trigger update_on_rdfnode2tc rdfnode 0 CREATE TRIGGER update_on_rdfnode2tc before update on rdfnode for each row
  when exists (select * from rdf_transitive_p where p = old.p)
  begin
   delete from rdf_tc_hook where s = old.s and o = old.o and p = old.p;
   insert into rdf_tc_hook(s,p,o) values(new.s, new.p, new.o);
  end) #(view literal_tproperty literal_tproperty 0 CREATE VIEW literal_tproperty as select v
  from literal join rdf_transitive_p as p on literal.s=p.p) #(trigger insert_on_literal_tproperty literal_tproperty 0 CREATE TRIGGER insert_on_literal_tproperty
   instead of insert on literal_tproperty for each row
  begin
   insert into literal_property(v) values(new.v);
   insert into rdfnode(s,p,o)
     select ls.s, 2 as p, lo.s from literal as ls join literal as lo
     on ls.v = new.s and lo.v = new.v;
  end) #(trigger insert_on_rdf_tprop rdfnode 0 CREATE TRIGGER insert_on_rdf_tprop after insert on rdfnode for each row
  when new.s = new.o and new.p = 2
  begin
   insert into rdf_tc_hook select * from rdfnode where p = new.s;
  end) #(trigger delete_on_rdf_tprop rdfnode 0 CREATE TRIGGER delete_on_rdf_tprop before delete on rdfnode for each row
  when old.s = old.o and old.p = 2
  begin
   delete from rdf_tc where p = old.s;
  end) #(view rdf_subClassOf_tc rdf_subClassOf_tc 0 CREATE VIEW rdf_subClassOf_tc as
  select tc.s as s, tc.o as o
  from rdf_tc as tc 
  join literal as lp on lp.s = tc.p and lp.v = 'http://www.w3.org/2000/01/rdf-schema#subClassOf') #(view literal_domain literal_domain 0 CREATE VIEW literal_domain as select s,o from rdflit
  where p = 'http://www.w3.org/2000/01/rdf-schema#domain') #(trigger insert_on_literal_domain literal_domain 0 CREATE TRIGGER insert_on_literal_domain
  instead of insert on literal_domain for each row
  begin
   insert into rdflit(s,p,o)
    select new.s,'http://www.w3.org/2000/01/rdf-schema#domain',new.o;
  end) #(view literal_range literal_range 0 CREATE VIEW literal_range as select s,o from rdflit
  where p = 'http://www.w3.org/2000/01/rdf-schema#range') #(trigger insert_on_literal_range literal_range 0 CREATE TRIGGER insert_on_literal_range
  instead of insert on literal_range for each row
  begin
   insert into rdflit(s,p,o)
    select new.s,'http://www.w3.org/2000/01/rdf-schema#range',new.o;
  end) #(view rdf_domain rdf_domain 0 CREATE VIEW rdf_domain as select t.s as s,o from rdfnode as t
  join literal on t.p = literal.s and literal.v = 'http://www.w3.org/2000/01/rdf-schema#domain'
  -- where p=10) #(view rdf_range rdf_range 0 CREATE VIEW rdf_range as select t.s as s,o from rdfnode as t
  join literal on t.p = literal.s and literal.v = 'http://www.w3.org/2000/01/rdf-schema#range'
  -- where p=11) #(view rdf_range_tc rdf_range_tc 0 CREATE VIEW rdf_range_tc as
  select r.s as s, r.o as o from rdf_range as r
  union all
  select r.s as s, t.o as o from rdf_range as r
   join rdf_tc as tc on r.o = tc.o
   join literal as lsubc on lsubc.s = tc.p and
    lsubc.v = 'http://www.w3.org/2000/01/rdf-schema#subClassOf'
  join rdfnode as t on r.s = t.s and r.o = t.o or tc.s = t.o) #(view rdf_domain_1 rdf_domain_1 0 CREATE VIEW rdf_domain_1 as
  select s,o from rdf_domain union all
  select sub.s as s, d.o as o
   from rdf_domain as d join rdf_subPropertyOf sub on d.s = sub.o) #(view rdf_domain_2 rdf_domain_2 0 CREATE VIEW rdf_domain_2 as
  select s,o from rdf_domain_1 union all
  select sub.s as s, d.o as o
   from rdf_domain_1 as d join rdf_subPropertyOf sub on d.s = sub.o) #(view rdf_domain_tc rdf_domain_tc 0 CREATE VIEW rdf_domain_tc as
  select * from rdf_domain
  union all
  select tc.s as s, d.o as o
  from rdf_domain as d join rdf_tc as tc on d.s = tc.o
  join literal as lsubp on lsubp.s = tc.p and
    lsubp.v = 'http://www.w3.org/2000/01/rdf-schema#subPropertyOf') #(trigger insert_on_literal_property literal_property 0 CREATE TRIGGER insert_on_literal_property
  instead of insert on literal_property for each row
  begin
   insert into literal_type(s,o)
    select new.v, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property';
  end) #(view rdf_datatype rdf_datatype 0 CREATE VIEW rdf_datatype as select t.s as s,o from rdfnode as t
   join literal on t.p = literal.s and literal.v = 'http://www.w3.org/2000/01/rdf-schema#Datatype'
   -- where p= ...) #(view rdf_member rdf_member 0 CREATE VIEW rdf_member as select t.s as s,o from rdfnode as t
   join literal on t.p = literal.s and literal.v = 'http://www.w3.org/2000/01/rdf-schema#member'
   -- where p= ...) #(view rdf_container_member rdf_container_member 0 CREATE VIEW rdf_container_member as select t.s as s, t.p as p, o from rdfnode as t
   join literal on t.p = literal.s
   and literal.v = 'http://www.w3.org/2000/01/rdf-schema#ContainerMembershipProperty'
   -- where p= ...) #(table template4datatype template4datatype 70 CREATE TABLE template4datatype (datatype integer primary key
  ,ro text
  ,edit text
  ,choose text)) #(view template4p template4p 0 CREATE VIEW template4p as
  select prd.s as p, coalesce(l.choose,'select-resource-o-listing') as template
   from rdf_range as prd
   left join template4datatype as l on l.datatype=prd.o) #(view rdf_type_plus_literal rdf_type_plus_literal 0 CREATE VIEW rdf_type_plus_literal as
  select t.id as s, c.o from rdfnode as t join rdf_type c on c.s = t.s
  union all
  select l.s,
   case l.cls
    when 0 then (select s from literal where v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral')
    when 10 then (select s from literal where v = 'http://www.w3.org/2000/01/rdf-schema#Literal')
    when 1000 then (select s from literal where v = 'urn:about:Literal1000')
   end as o
  from rdfnode as t join literal as l on l.s = t.id) #(view rdf_type_literal rdf_type_literal 0 CREATE VIEW rdf_type_literal as
  select l.s as s,
    case l.cls
      when 0 then (select s from literal where v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral')
      when 10 then (select s from literal where v = 'http://www.w3.org/2000/01/rdf-schema#Literal')
      when 1000 then (select s from literal where v = 'urn:about:Literal1000')
     end as o from rdfnode as t join literal as l on l.s = t.id) #(view rdf_type_resource rdf_type_resource 0 CREATE VIEW rdf_type_resource as
  select t.id as s,
   (select s from literal where v = 'http://www.w3.org/2000/01/rdf-schema#Resource') as o
   from rdfnode as t) #(view rdf_type_statement rdf_type_statement 0 CREATE VIEW rdf_type_statement as
  select t.id as s, l.s as o from rdfnode as t join literal as l
  on t.id != t.s and l.v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement') #(view rdf_type_by_def rdf_type_by_def 0 CREATE VIEW rdf_type_by_def as
  select t.id as s, c.o as o from rdfnode as t join rdf_type as c on c.id=t.id) #(view rdf_type_all rdf_type_all 0 CREATE VIEW rdf_type_all as
  select * from rdf_type_statement
  union all
  select * from rdf_type_literal
  union all
  select * from rdf_type_resource
  union all
  select s,o from rdf_type) #(view rdf_type_most rdf_type_most 0 CREATE VIEW rdf_type_most as
  select * from rdf_type_statement
  union all
  select * from rdf_type_literal
  union all
  select s,o from rdf_type) #(view rdf_type_impl rdf_type_impl 0 CREATE VIEW rdf_type_impl as
  select * from rdf_type_statement
  union all
  select * from rdf_type_literal
  union all
  select * from rdf_type_resource) #(view t4r_impl_stmt t4r_impl_stmt 0 CREATE VIEW t4r_impl_stmt as
  select n.id as id, 0.1 as quality, l.ro as ro, l.edit as edit, l.choose as choose
  from rdfnode as n join (select * from rdf_type_statement) as t on t.s = n.s
  join template4datatype as l on l.datatype=t.o) #(view t4r_impl_literal t4r_impl_literal 0 CREATE VIEW t4r_impl_literal as
  select n.id as id, 0.1 as quality, l.ro as ro, l.edit as edit, l.choose as choose
  from rdfnode as n join (select * from rdf_type_literal) as t on t.s = n.id
  join template4datatype as l on l.datatype=t.o) #(view t4r_impl_resource t4r_impl_resource 0 CREATE VIEW t4r_impl_resource as
  select n.id as id, 0.1 as quality, l.ro as ro, l.edit as edit, l.choose as choose
  from rdfnode as n join (select * from rdf_type_resource) as t on t.s = n.s
  join template4datatype as l on l.datatype=t.o) #(view template4r template4r 0 CREATE VIEW template4r as
  select * from t4r_type_def
  union all
  select * from t4r_impl_stmt
  union all
  select * from t4r_impl_literal
  union all
  select * from t4r_impl_resource) #(view literal_template4r literal_template4r 0 CREATE VIEW literal_template4r as select literal.v as s, ro, edit, choose
  from template4r join literal on template4r.id=literal.s) #(trigger insert_on_literal_template4r literal_template4r 0 CREATE TRIGGER insert_on_literal_template4r
  instead of insert on literal_template4r for each row
  begin
   insert into template4datatype(datatype,ro,edit,choose)
    select (select s from literal where v = new.s), new.ro, new.edit, new.choose;
  end) #(view template4r1 template4r1 0 CREATE VIEW template4r1 as select
   n.id as id, t.ro as ro, t.edit as edit
   from rdfnode as n join rdf_range as rng on rng.s=n.p
   join template4datatype as t on t.datatype=rng.o) #(view rdf_type_sequence rdf_type_sequence 0 CREATE VIEW rdf_type_sequence as select s from rdfnode
  where p = (select s from literal where v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
  and o = (select s from literal where v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq')) #(table rdf_sequence rdf_sequence 71 CREATE TABLE rdf_sequence(
   s integer references rdfnode(id) -- the sequence
  ,o integer references rdfnode(id) -- the container member
  ,v integer
  ,unique(s,o))) #(index sqlite_autoindex_rdf_sequence_1 rdf_sequence 72 #f) #(index rdf_sequence_s rdf_sequence 73 CREATE UNIQUE INDEX rdf_sequence_s on rdf_sequence(s,o,v)) #(view rdf_sequence_max rdf_sequence_max 0 CREATE VIEW rdf_sequence_max as
  select ds.s as s, coalesce(seq.v,dflt) as v
   from
    (select s, 0 as dflt from rdf_type_sequence) as ds
   left join (select s, max(v) as v from rdf_sequence group by s) as seq on seq.s = ds.s) #(trigger insert_on_rdf2seq rdfnode 0 CREATE TRIGGER insert_on_rdf2seq after insert on rdfnode for each row
  when new.p = (select s from literal where v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
  and  new.o = (select s from literal where v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq')
  begin
   insert into rdf_sequence(s,o,v)
    select new.id,o,n from rdf_container_member as m
    join (select count(*) as n from rdf_container_member where s = new.id)
    on m.s = new.id;
  end) #(trigger insert_on_rdf2seq_member rdfnode 0 CREATE TRIGGER insert_on_rdf2seq_member after insert on rdfnode for each row
  when
   new.p = (select s from literal where v = 'http://www.w3.org/2000/01/rdf-schema#ContainerMembershipProperty')
   and exists (select * from rdf_type_sequence where s = new.s)
  begin
   insert into rdf_sequence(s,o,v)
    select new.s,new.o,v+1 from rdf_sequence_max where s = new.s;
  end) #(trigger delete_on_rdfnode_4w_rdfSeq1 rdfnode 0 CREATE TRIGGER delete_on_rdfnode_4w_rdfSeq1 after delete on rdfnode for each row
  when
   old.p = (select s from literal where v = 'http://www.w3.org/2000/01/rdf-schema#ContainerMembershipProperty')
  begin
   delete from rdf_sequence where s = old.s and o = old.o;
  end) #(trigger delete_on_rdfnode_4w_rdfSeq2 rdfnode 0 CREATE TRIGGER delete_on_rdfnode_4w_rdfSeq2 after delete on rdfnode for each row
  begin
   delete from rdf_sequence where s = old.id;
  end) #(view rdf_ordered rdf_ordered 0 CREATE VIEW rdf_ordered as select * from rdf_sequence) #(trigger insert_on_rdf_ordered rdf_ordered 0 CREATE TRIGGER insert_on_rdf_ordered instead of insert on rdf_ordered for each row
  begin
   select
    case when new.v is null then 1
         when typeof(new.v) != 'integer' then raise(abort,'rdf#Seq ordinal not integer') end;
   insert into rdfnode(s,p,o)
    select new.s, literal.s, new.o from literal
    where v = 'http://www.w3.org/2000/01/rdf-schema#ContainerMembershipProperty';
   update rdf_sequence set v = new.v where not new.v is null and s = new.s and o = new.o;
  end) #(view literal_rdf_ordered literal_rdf_ordered 0 CREATE VIEW literal_rdf_ordered as select
  ls.v as s, lo.v as o, t.v from rdf_sequence as t
  join literal as ls on ls.s = t.s
  join literal as lo on lo.s = t.o) #(trigger insert_on_literal_rdf_ordered literal_rdf_ordered 0 CREATE TRIGGER insert_on_literal_rdf_ordered instead of insert on literal_rdf_ordered for each row
  begin
   insert into rdf_ordered(s,o,v)
    select
     (select s from literal where v = new.s),
     (select s from literal where v = new.o),
     new.v;
  end) #(view issue_state issue_state 0 CREATE VIEW issue_state as select
  ord.o as id, ord.v as s, l.v as n
  from rdf_ordered as ord
  join literal as cn on ord.s = cn.s and cn.v = 'urn:about:/hoist#IssueState'
  join literal as l on l.s = ord.o) #(view dim dim 0 CREATE VIEW dim as select
  t.id as id, l.v as n
  from rdfnode as t join literal as l on l.s = t.id
  join rdf_type as c on t.id = c.s
  join literal on c.o = literal.s and literal.v = 'urn:about:/hoist#Dimension') #(view payment_instrument_literal payment_instrument_literal 0 CREATE VIEW payment_instrument_literal as select
  t.s as s, c.s as pi, l.v as v
  from rdfnode as t
  join rdf_subClassOf as c on
   t.p = (select s from literal where v = 'urn:about:/hoist#costPaymentInstrument')
   and c.o = (select s from literal where v = 'urn:about:/hoist/Dimension/PaymentInstrument')
  join literal as l on l.s = c.s) #(view project project 0 CREATE VIEW project as select
  t.id as id
  ,c.id as r
  ,nm.v as name
  ,lnkv.v as link
  ,case
    when desc.cls = 10 then (select content from anywhere where docid = desc.id)
    else desc.v
   end as description
  ,dsc.o as desc
  ,case when pr.o is null or pr.o = 6 then 0 else pr.o end as pr
  ,case when pl.o is null or pl.o = 6 then 0 else pl.o end as pl
  from rdfnode as t
  join rdf_type as c on c.s = t.id join literal as tp on tp.s = c.o
   and tp.v = 'urn:about:/hoist#Project'
  left join rdfnode as label on label.s = t.id
   and label.p = (select s from literal where v = 'http://purl.org/dc/elements/1.1/title')
   join literal as nm on nm.s = label.o
  left join rdf_definition as lnk on lnk.s = t.id
  left join literal as lnkv on lnk.o = lnkv.s
  left join rdfnode as dsc on dsc.s = t.id
   and dsc.p = (select s from literal where v = 'http://purl.org/dc/elements/1.1/description')
  join literal as desc on dsc.o = desc.s
  left join rdfnode as pr on pr.s = t.id
   and pr.p = (select s from literal where v = 'urn:about:/hoist#open')
  left join rdfnode as pl on pl.s = t.id
   and pl.p = (select s from literal where v = 'urn:about:/hoist#visible')
  group by t.id) #(trigger insert_on_project project 0 CREATE TRIGGER insert_on_project instead of insert on project for each row
  begin
   insert into literal_v_de(v) select new.link;
   insert into rdfnode(s,p,o)
    select l.s, def.s, l.s from literal as l
    join literal as def on def.v = 'http://www.w3.org/2000/01/rdf-schema#isDefinedBy'
    where l.v = new.link;
   insert into rdfnode(s,p,o)
    select l.s, def.s, prj.s from literal as l
    join literal as def on def.v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
    join literal as prj on prj.v = 'urn:about:/hoist#Project'
    where l.v = new.link;
   insert into spo_o_literal(s,p,o)
    select l.s, name.s, new.name from literal as l
    join literal as name on name.v = 'http://purl.org/dc/elements/1.1/title'
    where l.v = new.link;
   insert into spo_o_literal(s,p,o)
    select l.s, description.s, new.description from literal as l
    join literal as description on description.v = 'http://purl.org/dc/elements/1.1/description'
    where l.v = new.link;
  end) #(trigger update_on_project2title project 0 CREATE TRIGGER update_on_project2title instead of update of title on project for each row
  when
   (select literal.v from project join literal on literal.s = project.id where project.id = new.id)
   != new.name and new.name != '' and not new.name is null
  begin
   delete from spo_deleteable where id in
    (select t.id from rdfnode as t
     join literal as title on title.v = 'http://purl.org/dc/elements/1.1/title'
     and t.p = title.s and t.s = new.id);
   insert into spo_o_literal(s,p,o)
    select new.id, name.s, new.name
    from literal as name where name.v = 'http://purl.org/dc/elements/1.1/title';
  end) #(trigger update_on_project2pr project 0 CREATE TRIGGER update_on_project2pr instead of update of pr on project for each row
  when new.pr != old.pr
  begin
   delete from rdfnode where s = old.id
    and p = (select s from literal where v = 'urn:about:/hoist#open');
   insert into rdfnode (s,p,o) select new.id, literal.s, 7
   from literal join rdfnode as t on t.id = literal.s and literal.v = 'urn:about:/hoist#open'
   where new.pr;
  end) #(trigger update_on_project2pl project 0 CREATE TRIGGER update_on_project2pl instead of update of pl on project for each row
  when new.pl != old.pl
  begin
   delete from rdfnode where s = old.id
    and p = (select s from literal where v = 'urn:about:/hoist#visible');
   insert into rdfnode (s,p,o) select new.id, literal.s, 7
   from literal join rdfnode as t on t.id = literal.s and literal.v = 'urn:about:/hoist#visible'
   where new.pl;
  end) #(view hoist_includes hoist_includes 0 CREATE VIEW hoist_includes as select id,s,o from rdfnode
  where p = (select s from literal where v = 'urn:about:/hoist#includes')) #(trigger delete_on_hoist_includes hoist_includes 0 CREATE TRIGGER delete_on_hoist_includes instead of delete on hoist_includes for each row
  begin
   delete from rdfnode where s = old.s and o = old.o
    and p = (select s from literal where v = 'urn:about:/hoist#includes');
  end) #(view milestone_core milestone_core 0 CREATE VIEW milestone_core as select
  t.id as id
  ,c.id as r
  ,project.s as project
  ,duedate.v as due
  ,nm.v as name
  ,dsc.o as description
  ,weight.v as weight
  ,weight.pi as dim
  ,case when deleted.o = 6 then 1 else 0 end as deleted
  from rdfnode as t
  join rdf_type as c on c.s = t.id join literal as tp on tp.s = c.o
   and tp.v = 'urn:about:/hoist#Milestone'
  join hoist_includes as project on project.o = t.id
  left join rdfnode as due on due.s = t.id
   and due.p = (select s from literal where v = 'urn:about:/hoist#due')
  left join literal as duedate on duedate.s = due.o
  left join rdfnode as label on label.s = t.id
   and label.p = (select s from literal where v = 'http://purl.org/dc/elements/1.1/title')
  left join literal as nm on nm.s = label.o
  left join rdfnode as dsc on dsc.s = t.id
   and dsc.p = (select s from literal where v = 'http://purl.org/dc/elements/1.1/description')
  left join payment_instrument_literal as weight on weight.s = t.id
  left join rdfnode as deleted on deleted.s = t.id
   and deleted.p = (select s from literal where v = 'urn:about:/hoist#visible')) #(trigger insert_on_milestone_core milestone_core 0 CREATE TRIGGER insert_on_milestone_core instead of insert on milestone_core for each row
  begin
   insert into rdf_ordered(s,o) select s, new.id from literal where v = 'urn:about:/hoist#Milestone';
   insert into spo_o_literal(s,p,o)
    select new.id, name.s, new.name
     from literal as name where name.v = 'http://purl.org/dc/elements/1.1/title';
   insert into spo_o_literal(s,p,o)
    select new.id, description.s, new.description
     from literal as description where description.v = 'http://purl.org/dc/elements/1.1/description';
   insert into rdfnode(s,p,o)
    select new.project, prd.s, new.id from
     literal as prd where prd.v = 'urn:about:/hoist#includes';
  end) #(view milestone milestone 0 CREATE VIEW milestone as select * from milestone_core) #(trigger insert_on_milestone milestone 0 CREATE TRIGGER insert_on_milestone instead of insert on milestone for each row
  begin
   insert into rdf_new_s_literal(v,p,o)
    select mx.v+1, def.s, c.s
     from literal as def
     join literal as c on c.v = 'urn:about:/hoist#Milestone'
       and def.v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
     join rdf_sequence_max as mx on mx.s = c.s;
   insert into milestone_core
    select
     (select s from rdfnode where id = (select max(id) from rdfnode)) as id,
     new.r as r,
     new.project as project, new.due as due,
     new.name as name, new.description as description, new.weight as weight,
     new.dim as dim, new.deleted as deleted;
  end) #(view hoist_remark hoist_remark 0 CREATE VIEW hoist_remark as select id,s,o from rdfnode
 -- join rdf_type on 'Issue'
  where p = (select s from literal where v = 'http://www.w3.org/2000/01/rdf-schema#comment')) #(trigger insert_on_hoist_remark hoist_remark 0 CREATE TRIGGER insert_on_hoist_remark instead of insert on hoist_remark for each row
  begin
   insert into rdfnode(s,p,o)
    select
     new.s,
     (select s from literal where v = 'http://www.w3.org/2000/01/rdf-schema#comment'),
     new.o;
  end) #(view issue_core issue_core 0 CREATE VIEW issue_core as select
  t.id as id
  ,c.id as r
  ,nm.v as subject
  ,issue_state.s as state
  ,rem.s as project
  ,weight.pi as dim
  ,weight.v as weight
  from rdfnode as t
  join rdf_type as c on c.s = t.id
   join literal on c.o = literal.s and literal.v = 'urn:about:/hoist#Issue'
  left join rdfnode as subject on subject.s = t.id
   and subject.p = (select s from literal where v = 'http://purl.org/dc/elements/1.1/title')
  join literal as nm on nm.s = subject.o
  left join rdfnode as state on state.s = t.id
   and state.p = (select s from literal where v = 'urn:about:/hoist#state')
  left join issue_state on issue_state.id = state.o
  left join hoist_remark as rem on rem.o = t.id
  left join payment_instrument_literal as weight on weight.s = t.id) #(trigger insert_on_issue_core issue_core 0 CREATE TRIGGER insert_on_issue_core instead of insert on issue_core for each row
  begin
   insert into rdf_ordered(s,o) select s, new.id from literal where v = 'urn:about:/hoist#Issue';
   insert into spo_o_literal(s,p,o)
    select new.id, name.s, new.subject
     from literal as name where name.v = 'http://purl.org/dc/elements/1.1/title';
   insert into hoist_remark(s,o) select new.project, new.id;
   insert into rdfnode(s,p,o)
    select new.id, stat.s, sub.s
     from literal as stat join literal as sub
     on stat.v = 'urn:about:/hoist#state'
     and sub.v = 'urn:about:/hoist/IssueState/submitted';
  end) #(view issue issue 0 CREATE VIEW issue as select * from issue_core) #(trigger insert_on_issue issue 0 CREATE TRIGGER insert_on_issue instead of insert on issue for each row
  begin
   insert into rdf_new_s_literal(v,p,o)
    select mx.v+1, def.s, c.s
     from literal as def
     join literal as c on c.v = 'urn:about:/hoist#Issue'
       and def.v = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
     join rdf_sequence_max as mx on mx.s = c.s;
   insert into issue_core(id,state,project,subject)
    select
     (select s from rdfnode where id = (select max(id) from rdfnode)) as id,
     new.state as state, new.project as project,
     new.subject as subject;
  end) #(trigger delete_on_issue issue 0 CREATE TRIGGER delete_on_issue instead of delete on issue for each row
  begin
   delete from spo_deleteable where id in
    (select t.id from rdfnode as t join literal as l on l.s = t.p
    where t.s = old.id and l.v in
    ('http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
     'http://purl.org/dc/elements/1.1/title',
     'urn:about:/hoist#state'
     ));
   delete from spo_deleteable where id = old.id;
  end) #(view dependency dependency 0 CREATE VIEW dependency as select
  t.o as goal
  ,t.s as need
  from rdfnode as t
   where t.p = (select s from literal where v = 'urn:about:/hoist#blocks')
--  primary key(goal, need) on conflict ignore) #(trigger insert_on_dependency dependency 0 CREATE TRIGGER insert_on_dependency instead of insert on dependency for each row
  begin
   insert into rdfnode(s,p,o)
    select new.need, literal.s, new.goal from literal where v = 'urn:about:/hoist#blocks';
  end) #(trigger delete_on_dependency dependency 0 CREATE TRIGGER delete_on_dependency instead of delete on dependency for each row
  begin
   delete from rdfnode where s = old.need and o = old.goal
    and p = (select s from literal where v = 'urn:about:/hoist#blocks');
  end) #(view event event 0 CREATE VIEW event as select
  t.id as id
  ,t.s as issue
  ,moment.v as moment -- datetime
  ,author.v as author
  ,t.o as comment
  ,case when deleted.o = 6 then 1 else 0 end as deleted
  from hoist_remark as t
  left join rdfnode as created on created.s = t.o
   and created.p = (select s from literal where v = 'http://purl.org/dc/terms/created')
  left join literal as moment on moment.s = created.o
  left join rdfnode as creator on creator.s = t.o
   and creator.p = (select s from literal where v = 'http://purl.org/dc/terms/creator')
  left join literal as author on author.s = creator.o
  left join rdfnode as deleted on deleted.s = t.o
   and deleted.p = (select s from literal where v = 'urn:about:/hoist#visible')) #(trigger insert_on_event event 0 CREATE TRIGGER insert_on_event instead of insert on event for each row
  begin
   insert into spo_o_literal(s,p,o) select new.id,s,new.moment
    from literal where v = 'http://purl.org/dc/terms/created';
   insert into spo_o_literal(s,p,o) select new.id,s,new.author
    from literal where v = 'http://purl.org/dc/terms/creator';
  end) #(trigger update_on_event_del event 0 CREATE TRIGGER update_on_event_del instead of update of deleted on event for each row
  when new.deleted and not (select deleted from event where id = old.id)
  begin
   insert into rdfnode (s,p,o) select t.o, literal.s, 6
   from literal join rdfnode as t on literal.v = 'urn:about:/hoist#visible'
   and t.id = old.id where new.deleted;
   delete from rdfnode where not new.deleted and id in
    (select id from rdfnode where s = old.id
     and p = (select s from literal where v = 'urn:about:/hoist#visible'));
  end) #(trigger update_on_event_issue event 0 CREATE TRIGGER update_on_event_issue instead of update of issue on event for each row
  begin
   update rdfnode set s = new.issue
   where id = (select id from hoist_remark where s = old.issue);
  end) #(view hoist_attachment_core hoist_attachment_core 0 CREATE VIEW hoist_attachment_core as select
  t.id as id, t.s as s, t.o as o
  from rdfnode as t join literal as m on m.s = t.p and m.v = 'urn:about:/hoist#seeAlso') #(view hoist_att_ttl hoist_att_ttl 0 CREATE VIEW hoist_att_ttl as select t.id as id, t.s as s, t.o as o
  from rdfnode as t join literal
   on t.p = literal.s and literal.v = 'http://purl.org/dc/elements/1.1/title') #(view hoist_attachment hoist_attachment 0 CREATE VIEW hoist_attachment as select
  t.id as id
  ,t.s as event
  ,lit.v as oid
  ,lit.cls as cls
  ,coalesce(group_concat(ltt.v, ', '), './.') as title
  from hoist_attachment_core as t
  join literal as lit on lit.s = t.o
  left join hoist_att_ttl as ttl on ttl.s = t.id
  left join literal as ltt on ltt.s = ttl.o
  group by event, oid) #(trigger insert_on_hoist_attachment hoist_attachment 0 CREATE TRIGGER insert_on_hoist_attachment instead of insert on hoist_attachment for each row
  begin
   insert into spo_o_literal select new.event, seep.s, new.oid
    from literal as seep where seep.v = 'urn:about:/hoist#seeAlso';
   update literal set cls = new.cls where v = new.oid;
   insert into spo_o_literal select t.id, ttl.s, new.title
    from hoist_attachment_core as t
    join literal as ttl on ttl.v = 'http://purl.org/dc/elements/1.1/title'
    and t.o = (select s from literal where v = new.oid)
    where new.title is not null and new.title != ''
     and not new.title in (select v from literal where s = t.o);
  end) #(trigger delete_on_hoist_attachment hoist_attachment 0 CREATE TRIGGER delete_on_hoist_attachment instead of delete on hoist_attachment for each row
  begin
   -- first aux info
   delete from spo_deleteable where id in (select id from rdfnode where s = old.id);
   delete from rdfnode where id = old.id; -- then the statement itself
  end) #(view newsfeed newsfeed 0 CREATE VIEW newsfeed as select
  t.id as id
  ,(select v from l4r where s = ttl.o) as title
  ,(select v from l4r where s = publ.o) as published
  ,desc.o as description
  ,'atomentry' as items
  from
  rdfnode as t
  join rdfnode as ttl on ttl.s = t.id
  join literal as ttlp on ttl.p = ttlp.s
   and ttlp.v = 'http://purl.org/dc/elements/1.1/title'
  join rdfnode as desc on desc.s = t.id
  join literal as descp on desc.p = descp.s
   and descp.v = 'http://purl.org/dc/elements/1.1/description'
  left join rdfnode as publ on publ.s = t.id
  and publ.p = (select s from literal where v = 'http://purl.org/dc/terms/issued')) #(view atomentry atomentry 0 CREATE VIEW atomentry as select
  desc.o as id
  ,feed.s as feed
  ,(select v from l4r where s = ttl.o) as title
  ,(select v from l4r where s = publ.o) as published
  ,desc.o as description
  from
  rdfnode as t
  join rdfnode as ttl on ttl.s = t.id
  join literal as ttlp on ttl.p = ttlp.s
   and ttlp.v = 'http://purl.org/dc/elements/1.1/title'
  join rdfnode as desc on desc.s = t.id
  join literal as descp on desc.p = descp.s
   and descp.v = 'http://www.w3.org/2000/01/rdf-schema#comment'
  join rdfnode as publ on publ.s = desc.o
  and publ.p = (select s from literal where v = 'http://purl.org/dc/terms/created')
  join rdfnode as feed on feed.o = t.s
   and feed.p = (select s from literal where v = 'http://www.w3.org/2000/01/rdf-schema#comment')) #(table worklog worklog 74 CREATE TABLE worklog(id integer primary key autoincrement
  ,agent integer
  ,issue integer
  ,start real -- julian day
  ,finish real
  ,comment text
 )) #(view dc_agent dc_agent 0 CREATE VIEW dc_agent as select * from rdf_type
  where o = (select s from literal where v = 'http://purl.org/dc/terms/Agent')) #(table l10n_en l10n_en 75 CREATE TABLE l10n_en (orig text unique, display text not null, unique(orig,display))) #(index sqlite_autoindex_l10n_en_1 l10n_en 76 #f) #(index sqlite_autoindex_l10n_en_2 l10n_en 77 #f) #(trigger literal2rdfnode literal 0 CREATE TRIGGER literal2rdfnode after insert on literal for each row
  begin
   select raise(abort, 'empty literal value')
    where new.v = ''; -- FIXME need a broader predicate
   insert into rdfnode(s,p,o) values(9,0,0);
   update rdfnode set s = last_insert_rowid() where _rowid_ = last_insert_rowid();
   update literal set s = last_insert_rowid() where new.id = id;
  end) #(trigger literal2anywhere literal 0 CREATE TRIGGER literal2anywhere after insert on literal for each row
--  when new.v like '% % %'
  when not
   (new.v like 'http://%' or new.v like 'https://%'
    or new.v like 'mailto:%' or new.v like 'urn:%')
  begin
   insert into anywhere(docid,content) values(last_insert_rowid(),new.v);
  end) #(view t4r_type_def t4r_type_def 0 CREATE VIEW t4r_type_def as
  select n.id as id, 1.0 as quality, l.ro as ro, l.edit as edit, l.choose as choose
  from rdfnode as n join rdf_type as t on t.id = n.id
  join template4datatype as l on l.datatype=t.o) #(table param param 78 CREATE TABLE param (id integer not null,s integer ,p integer ,o integer)) #(trigger param_isempty param 0 CREATE TRIGGER param_isempty before insert on param for each row
  begin select raise(abort,'table "param" is intentionally empty'); end))

As XML