  -- type system. system nodes have keys <= 0
 create table if not exists kind (
   knd integer primary key,
-  foreign key (knd) references node (nid) );
+  foreign key (knd) references node (nid));
 -- 
 insert or ignore into node (nid, knd, val) values

  instead of insert on trip
  begin
    insert or ignore into node (val) values (new.sub), (new.rel), (new.obj);
    insert into edge (sub, rel, obj, began)
    select (select nid from node where val=new.sub) as subID,
           (select nid from node where val=new.rel) as relID,
           (select nid from node where val=new.obj) as objID,
	   'now' as began;
    replace into meta ('k','v')
      values ('last_insert_rowid', last_insert_rowid());
  end;

------------------------------------------------------------------
create table if not exists node (
  nid integer primary key,
  knd integer  not null default 0,
  val, -- (can be any of the sqlite primitive types)
  foreign key(knd) references kind deferrable initially deferred );

