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

  rel integer references node,
  obj integer references node,
  seq integer not null default 0,
  began datetime default 'now',
  ended datetime default null );
--  unique (sub, rel, obj, seq) );


  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, seq, 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,
           new.seq,
	   datetime('now') as began;
    replace into meta ('k','v')
      values ('last_insert_rowid', last_insert_rowid());
  end;
