TheMathemagicians/sevenkeys/database/sql/createdb.sql

40 lines
1.0 KiB
SQL

CREATE DATABASE IF NOT EXISTS sevenkeys;
USE sevenkeys;
CREATE TABLE IF NOT EXISTS CacheTimestamp (
CacheType ENUM('AllCardsBulkData') PRIMARY KEY,
Stamp DATETIME NOT NULL
);
CREATE TABLE IF NOT EXISTS ExpansionSet (
SetCode VARCHAR(6) PRIMARY KEY,
Name VARCHAR(60) NOT NULL,
CardCount INT NOT NULL,
IconSvgUri VARCHAR(60) NOT NULL
);
CREATE TABLE IF NOT EXISTS CardPrinting (
Id VARCHAR(36) PRIMARY KEY, -- GUID
Name VARCHAR(150) NOT NULL,
SetCode VARCHAR(6) NOT NULL,
FOREIGN KEY (SetCode) REFERENCES ExpansionSet(SetCode),
HasFoil BOOLEAN NOT NULL,
HasNonFoil BOOLEAN NOT NULL,
IsReserved BOOLEAN NOT NULL,
IsRacist BOOLEAN NOT NULL,
IsPromo BOOLEAN NOT NULL,
CollectorNumber VARCHAR(10) NOT NULL,
Language VARCHAR(3) NOT NULL
);
CREATE TABLE IF NOT EXISTS CardStorageLocation (
Id INT AUTO_INCREMENT PRIMARY KEY,
CardPrintingId VARCHAR(36) NOT NULL,
FOREIGN KEY (CardPrintingId) REFERENCES CardPrinting(Id),
IsFoil BOOLEAN NOT NULL,
StorageBox VARCHAR(20) NOT NULL,
Source VARCHAR(100) NULL,
Position INT NOT NULL
);