word: kind table to link optional categories
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 25 Aug 2021 21:22:13 +0000 (23:22 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 25 Oct 2021 14:33:21 +0000 (16:33 +0200)
Allow for some kind of 20 Questions and other tagging.
The hard part will be filling and utilising it properly.

tools/word.pg.sql

index ec552c968b4a0add4f328d6e676deb434eccad60..eabf17deb8b6e2bc4b6bbdc7b382ed68a9eff7ed 100644 (file)
@@ -30,7 +30,7 @@ CREATE TABLE word (
 COMMENT ON COLUMN word.form       IS 'preferred textual representation';
 COMMENT ON COLUMN word.alt        IS 'alternate forms with equivalent meaning';
 COMMENT ON COLUMN word.lang       IS 'ISO 639 language code matching wikipedia subdomain';
-COMMENT ON COLUMN word.cat        IS 'hierarchical classification';
+COMMENT ON COLUMN word.cat        IS 'primary hierarchical classification';
 COMMENT ON COLUMN word.ref        IS 'reference to equivalent en translation';
 COMMENT ON COLUMN word.prio       IS 'difficulty level or importance; lower values have precedence';
 COMMENT ON COLUMN word.grade      IS 'ascending hierarchical order, preceding default alphabetical';
@@ -42,6 +42,19 @@ COMMENT ON COLUMN word.story      IS 'paragraph defining or describing the entit
 COMMENT ON COLUMN word.updated    IS 'last significant change';
 COMMENT ON COLUMN word.creator    IS 'user responsible for initial submit';
 
+CREATE TABLE kind (
+       word       integer     NOT NULL REFERENCES word (id),
+       cat        integer     NOT NULL REFERENCES word (id),
+                                       UNIQUE (word, cat),
+       truth      smallint    NOT NULL DEFAULT '50',
+       creator    integer              REFERENCES login (id),
+       created    timestamptz          DEFAULT now(),
+       updated    timestamptz,
+       id         serial      NOT NULL PRIMARY KEY
+);
+
+COMMENT ON COLUMN kind.truth      IS 'link validity ranging from 0 (never) to 100 (always)';
+
 CREATE OR REPLACE FUNCTION exportform(word) RETURNS text AS $$
        SELECT concat(
                $1.id, ':',