From d552052b813e0b82fc274d00152ad34a97cc8cc6 Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Sun, 9 Nov 2025 16:49:37 +0100 Subject: Outline of ftag internals The first version will essentially consist in performing the SELECT query at the end of this example SQL script. --- src/init.sql | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/init.sql (limited to 'src/init.sql') diff --git a/src/init.sql b/src/init.sql new file mode 100644 index 0000000..339ec55 --- /dev/null +++ b/src/init.sql @@ -0,0 +1,30 @@ +CREATE TABLE tags ( + id INTEGER NOT NULL PRIMARY KEY, + name VARCHAR(255), + description TEXT +); + +CREATE TABLE files ( + id INTEGER NOT NULL PRIMARY KEY, + name VARCHAR(255), + description TEXT +); + +CREATE TABLE file_tags ( + file INTEGER, + tag INTEGER, + FOREIGN KEY(file) REFERENCES files(id), + FOREIGN KEY(tag) REFERENCES tags(id) +); + +INSERT INTO tags VALUES(0, 'inria', 'Document lié à Inria'); +INSERT INTO tags VALUES(1, 'enseirb', 'Document lié à Enseirb'); + +INSERT INTO files VALUES(0, 'contrat_these.pdf', 'Contrat de travail pour la thèse.'); + +INSERT INTO file_tags VALUES(0 ,0); + +-- Query: all files related to Inria +SELECT name, description FROM ( + files JOIN file_tags ON files.id = file_tags.file +) WHERE file_tags.tag = 0; -- cgit v1.2.3