@ -1,12 +1,13 @@
-- Creating the DB structure
-- Creating the DB structure
-- Version 1. 3 (2021-08-14 )
-- Version 1. 4 (2021-10-10 )
CREATE TABLE IF NOT EXISTS Art (
CREATE TABLE IF NOT EXISTS Art (
ID INTEGER PRIMARY KEY generated always as identity ,
ID INTEGER PRIMARY KEY generated always as identity ,
md5_hash CHAR ( 32 ) NOT NULL UNIQUE ,
md5_hash CHAR ( 32 ) NOT NULL UNIQUE ,
path VARCHAR NOT NULL UNIQUE ,
path VARCHAR NOT NULL UNIQUE ,
title VARCHAR ,
title VARCHAR ,
link VARCHAR
link VARCHAR ,
description VARCHAR
) ;
) ;
CREATE TABLE IF NOT EXISTS Artist (
CREATE TABLE IF NOT EXISTS Artist (
@ -29,6 +30,21 @@ CREATE TABLE IF NOT EXISTS Presence (
FOREIGN KEY ( artist_ID ) REFERENCES Artist ( ID ) ON DELETE CASCADE
FOREIGN KEY ( artist_ID ) REFERENCES Artist ( ID ) ON DELETE CASCADE
) ;
) ;
CREATE TABLE IF NOT EXISTS 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 (
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 ( art_ID ) REFERENCES Art ( ID )
) ;
CREATE TABLE IF NOT EXISTS Art_Author (
CREATE TABLE IF NOT EXISTS Art_Author (
presence_name CHAR ( 20 ) NOT NULL ,
presence_name CHAR ( 20 ) NOT NULL ,
presence_domain CHAR ( 20 ) NOT NULL ,
presence_domain CHAR ( 20 ) NOT NULL ,
@ -88,7 +104,7 @@ GRANT CONNECT ON
DATABASE artnet
DATABASE artnet
TO artnet_editor ;
TO artnet_editor ;
GRANT SELECT , INSERT , UPDATE , DELETE ON
GRANT SELECT , INSERT , UPDATE , DELETE ON
TABLE art , art_author , tag_category , art_tag , artist_topic , artist , presence , tag , tag_alias , tag_implication , topic
TABLE art , art_author , tag_category , art_tag , artist_topic , artist , presence , tag , tag_alias , tag_implication , topic , collection , art_collection
TO artnet_editor ;
TO artnet_editor ;
GRANT USAGE ON
GRANT USAGE ON