
-- create triples views

create or replace view vtriples as
select triples.id,
       stype, svalue, predicate, otype, ovalue, creation,
       show_type(stype) as stname, 
       show_value(stype, svalue) as stext, 
       show_value(dt.id, predicate) as ptext, 
       show_type(otype) as otname,
       show_value(otype, ovalue) as otext,
       to_char(events.tstamp, 'YYYY-MM-DD HH24:MI:SS') as ts
  from triples, datatypes dt, events
  where dtname = 'node'
    and events.id = creation
    and deletion is null
;
