-- Related articles under each web issue article: the nearest embedded articles -- across the whole archive, computed when the issue is published (and by -- `features related` for older issues). Stored rather than computed per page -- view because finding them is a scan of every cached embedding. CREATE TABLE issue_related ( issue_date TEXT NOT NULL REFERENCES issues(date) ON DELETE CASCADE, article_id INTEGER NOT NULL REFERENCES articles(id) ON DELETE CASCADE, position INTEGER NOT NULL, -- 0 = closest related_id INTEGER NOT NULL REFERENCES articles(id) ON DELETE CASCADE, cosine REAL NOT NULL, PRIMARY KEY (issue_date, article_id, position) );