From 09a0ea0fbc59b001f5cc06ee450730c60d988dd8 Mon Sep 17 00:00:00 2001 From: The Magician Date: Sun, 28 Apr 2024 15:14:22 +0100 Subject: [PATCH] Add DB schema for tournament decklists --- sevenkeys/sql/createdb.sql | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sevenkeys/sql/createdb.sql b/sevenkeys/sql/createdb.sql index c0a0524..ec2553d 100644 --- a/sevenkeys/sql/createdb.sql +++ b/sevenkeys/sql/createdb.sql @@ -14,3 +14,26 @@ CREATE TABLE IF NOT EXISTS CardPrinting ( SetCode VARCHAR(6) NOT NULL, ImageUrl VARCHAR(2048) NOT NULL ); + +CREATE TABLE IF NOT EXISTS TournamentDecklist ( + Id INT AUTO_INCREMENT PRIMARY KEY, + DeckName VARCHAR(100) NOT NULL, + DatePublished DATE NOT NULL, + Source VARCHAR(200) NOT NULL, + Format VARCHAR(25) NOT NULL, + AuthorName VARCHAR(100) NOT NULL +); + +CREATE TABLE IF NOT EXISTS TournamentDecklistCard ( + TournamentDecklistId INT NOT NULL, + GamepieceId INT NOT NULL, + PRIMARY KEY (TournamentDecklistId, GamepieceId), + + FOREIGN KEY TournamentDecklistId REFERENCES TournamentDecklist(Id), + FOREIGN KEY GamepieceId REFERENCES Gamepiece(Id), + + CardPrintingId INT NULL, + FOREIGN KEY CardPrintingId REFERENCES CardPrinting(Id), + + Quantity INT NOT NULL +);