From 89f535c6f51ac138907b1aad84909f422fa21fa1 Mon Sep 17 00:00:00 2001 From: Dmitry Makarov Date: Wed, 11 Mar 2026 20:20:09 +0300 Subject: [PATCH] Catalog of notes --- postgres/drafts/07_notes.sql | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 postgres/drafts/07_notes.sql diff --git a/postgres/drafts/07_notes.sql b/postgres/drafts/07_notes.sql new file mode 100755 index 00000000..e0041754 --- /dev/null +++ b/postgres/drafts/07_notes.sql @@ -0,0 +1,26 @@ +BEGIN; + +CREATE SCHEMA note ; + +CREATE TABLE nature.data ( + record_id Text PRIMARY KEY REFERENCES layer0.records(id) ON UPDATE cascade ON DELETE restrict +, note Text NOT NULL +) ; + +CREATE VIEW layer2.notes AS +SELECT + r.pgc +, d.note +, t.bib +, b.code +, b.year +, b.author +, b.title +FROM + note.data AS d + LEFT JOIN layer0.records AS r ON (d.record_id = r.id) + LEFT JOIN layer0.tables AS t ON (r.table_id = t.id) + LEFT JOIN common.bib AS b ON (t.bib = b.id) +; + +COMMIT; \ No newline at end of file