From 258bbc79b73067b0bc9e04d3ea9aea58a713b1a0 Mon Sep 17 00:00:00 2001 From: Peery Date: Sun, 10 Oct 2021 16:51:51 +0200 Subject: [PATCH] Schema Version 2.0 (Table Renaming) Renamed art_author to art_to_presence Renamed collection to art_collection Renamed art_collection to art_to_art_collection Renamed artist_topic to artist_to_topic Renamed art_tag to art_to_tag --- Create_DB.sql | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Create_DB.sql b/Create_DB.sql index 7ee4093..6d7a8f6 100644 --- a/Create_DB.sql +++ b/Create_DB.sql @@ -1,5 +1,5 @@ -- Creating the DB structure --- Version 1.4 (2021-10-10) +-- Version 2.0 (2021-10-10) CREATE TABLE IF NOT EXISTS Art ( ID INTEGER PRIMARY KEY generated always as identity, @@ -30,22 +30,22 @@ CREATE TABLE IF NOT EXISTS Presence ( FOREIGN KEY (artist_ID) REFERENCES Artist(ID) ON DELETE CASCADE ); -CREATE TABLE IF NOT EXISTS Collection ( -- for ordered lists of art +CREATE TABLE IF NOT EXISTS Art_Collection ( -- for ordered lists of art ID INTEGER PRIMARY KEY generated always as identity, name VARCHAR, description VARCHAR ); -CREATE TABLE IF NOT EXISTS Art_Collection ( +CREATE TABLE IF NOT EXISTS Art_to_Art_Collection ( collection_ID INTEGER NOT NULL, art_ID INTEGER NOT NULL, ranking VARCHAR, -- order in the collection by string value, allows easy insert see https://stackoverflow.com/questions/9536262/best-representation-of-an-ordered-list-in-a-database; same rank or empty rank means unordered PRIMARY KEY (collection_ID, art_ID), - FOREIGN KEY (collection_ID) REFERENCES Collection(ID) ON DELETE CASCADE, + FOREIGN KEY (collection_ID) REFERENCES Art_Collection(ID) ON DELETE CASCADE, FOREIGN KEY (art_ID) REFERENCES Art(ID) ); -CREATE TABLE IF NOT EXISTS Art_Author ( +CREATE TABLE IF NOT EXISTS Art_to_Presence ( presence_name CHAR(20) NOT NULL, presence_domain CHAR(20) NOT NULL, art_ID INTEGER NOT NULL, @@ -54,7 +54,7 @@ CREATE TABLE IF NOT EXISTS Art_Author ( FOREIGN KEY (art_ID) REFERENCES Art(ID) ON UPDATE CASCADE ON DELETE CASCADE ); -CREATE TABLE IF NOT EXISTS Artist_Topic ( -- TODO implement, meant to indicate an artists main topics +CREATE TABLE IF NOT EXISTS Artist_to_Topic ( -- TODO implement, meant to indicate an artists main topics artist_ID INTEGER NOT NULL, topic_ID INTEGER NOT NULL, PRIMARY KEY (artist_ID, topic_ID), @@ -62,12 +62,12 @@ CREATE TABLE IF NOT EXISTS Artist_Topic ( -- TODO implement, meant to indicate FOREIGN KEY (topic_ID) REFERENCES Topic(ID) ON UPDATE CASCADE ON DELETE CASCADE ); -CREATE TABLE IF NOT EXISTS tag_category ( +CREATE TABLE IF NOT EXISTS Tag_Category ( category_id INTEGER PRIMARY KEY generated always as identity, name CHAR(20) NOT NULL ); -CREATE TABLE IF NOT EXISTS tag ( +CREATE TABLE IF NOT EXISTS Tag ( tag_ID INTEGER PRIMARY KEY generated always as identity, name CHAR(50) UNIQUE, description VARCHAR, @@ -75,7 +75,7 @@ CREATE TABLE IF NOT EXISTS tag ( FOREIGN KEY (category_id) REFERENCES tag_category(category_id) ); -CREATE TABLE IF NOT EXISTS Art_Tag ( +CREATE TABLE IF NOT EXISTS Art_to_Tag ( art_ID INTEGER, tag_ID INTEGER, PRIMARY KEY (art_ID, tag_ID), @@ -104,7 +104,7 @@ GRANT CONNECT ON DATABASE artnet TO artnet_editor; GRANT SELECT, INSERT, UPDATE, DELETE ON - TABLE art, art_author, tag_category, art_tag, artist_topic, artist, presence, tag, tag_alias, tag_implication, topic, collection, art_collection + TABLE art, art_to_presence, tag_category, art_to_tag, artist_to_topic, artist, presence, tag, tag_alias, tag_implication, topic, art_collection, art_to_art_collection TO artnet_editor; GRANT USAGE ON