+CREATE OR REPLACE VIEW _word_ref AS
+ SELECT
+ r.form, r.alt, r.lang,
+ coalesce(r.cat, w.cat ) cat, --TODO translate w?
+ coalesce(r.ref, r.id ) "ref",
+ coalesce(r.prio, w.prio ) prio,
+ coalesce(r.grade, w.grade ) grade,
+ coalesce(r.cover, w.cover ) cover,
+ coalesce(r.source, w.source ) source,
+ coalesce(r.thumb, w.thumb ) thumb,
+ coalesce(r.wptitle, w.wptitle) wptitle,
+ coalesce(r.story, w.story ) story,
+ r.creator, r.created, r.updated,
+ CASE WHEN r.source IS NULL THEN w.id ELSE r.id END id -- image id
+ FROM word r
+ LEFT JOIN word w ON w.id = r.ref;
+