Design first draft of database schema
This commit is contained in:
parent
529860f2bc
commit
07ad091168
|
@ -1,5 +1,115 @@
|
||||||
USE DATABASE sevenkeys;
|
USE DATABASE sevenkeys;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS CardPrinting;
|
CREATE TABLE IF NOT EXISTS Gamepiece (
|
||||||
|
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
OracleId VARCHAR(36) NOT NULL,
|
||||||
|
Name VARCHAR(141) NOT NULL,
|
||||||
|
Layout ENUM("normal",
|
||||||
|
"split",
|
||||||
|
"flip",
|
||||||
|
"transform",
|
||||||
|
"modal_dfc",
|
||||||
|
"meld",
|
||||||
|
"leveler",
|
||||||
|
"class",
|
||||||
|
"case",
|
||||||
|
"saga",
|
||||||
|
"adventure",
|
||||||
|
"mutate",
|
||||||
|
"prototype",
|
||||||
|
"battle",
|
||||||
|
"planar",
|
||||||
|
"scheme",
|
||||||
|
"vanguard",
|
||||||
|
"token",
|
||||||
|
"double_faced_token",
|
||||||
|
"emblem",
|
||||||
|
"augment",
|
||||||
|
"host",
|
||||||
|
"art_series",
|
||||||
|
"reversible_card") NOT NULL,
|
||||||
|
ManaCost VARCHAR(8) NOT NULL,
|
||||||
|
ManaValue FLOAT(7,2) NOT NULL,
|
||||||
|
TypeLine VARCHAR(50) NOT NULL,
|
||||||
|
OracleText VARCHAR(800) NOT NULL,
|
||||||
|
Power VARCHAR(5) NULL,
|
||||||
|
Toughness VARCHAR(5) NULL,
|
||||||
|
Legalities, -- TODO: many-to-many table
|
||||||
|
ReserveList BOOLEAN NOT NULL,
|
||||||
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS Gamepiece;
|
CREATE TABLE IF NOT EXISTS Color (
|
||||||
|
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
Name VARCHAR(5) NOT NULL,
|
||||||
|
Abbreviation VARCHAR(1) NOT NULL
|
||||||
|
);
|
||||||
|
INSERT INTO Color (Name, Abbreviation) VALUES ("White", "W");
|
||||||
|
INSERT INTO Color (Name, Abbreviation) VALUES ("Blue", "U");
|
||||||
|
INSERT INTO Color (Name, Abbreviation) VALUES ("Black", "B");
|
||||||
|
INSERT INTO Color (Name, Abbreviation) VALUES ("Red", "R");
|
||||||
|
INSERT INTO Color (Name, Abbreviation) VALUES ("Green", "G");
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS GamepieceColor (
|
||||||
|
ColorId INT,
|
||||||
|
GamepieceId INT,
|
||||||
|
PRIMARY KEY (ColorId, GamepieceId),
|
||||||
|
FOREIGN KEY (ColorId) REFERENCES Color(Id),
|
||||||
|
FOREIGN KEY (GamepieceId) REFERENCES Gamepiece(Id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS GamepieceColorIdentity (
|
||||||
|
ColorId INT,
|
||||||
|
GamepieceId INT,
|
||||||
|
PRIMARY KEY (ColorId, GamepieceId),
|
||||||
|
FOREIGN KEY (ColorId) REFERENCES Color(Id),
|
||||||
|
FOREIGN KEY (GamepieceId) REFERENCES Gamepiece(Id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS Keyword (
|
||||||
|
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
Name VARCHAR(20) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS GamepieceKeywords (
|
||||||
|
GamepieceId INT NOT NULL,
|
||||||
|
KeywordId INT NOT NULL,
|
||||||
|
PRIMARY KEY (GamepieceId, KeywordId),
|
||||||
|
FOREIGN KEY (GamepieceId) REFERENCES Gamepiece(Id),
|
||||||
|
FOREIGN KEY (KeywordId) REFERENCES Keyword(Id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS Format (
|
||||||
|
Id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
Name VARCHAR(50)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS GamepieceFormatLegality (
|
||||||
|
GamepieceId INT NOT NULL,
|
||||||
|
FormatId INT NOT NULL,
|
||||||
|
PRIMARY KEY (GamepieceId, FormatId),
|
||||||
|
FOREIGN KEY (GamepieceId) REFERENCES Gamepiece(Id),
|
||||||
|
FOREIGN KEY (FormatId) REFERENCES Format(Id),
|
||||||
|
Legality ENUM("legal", "not_legal", "restricted", "banned") NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS CardPrinting (
|
||||||
|
Id INT AUTO_INCREMENT NOT NULL,
|
||||||
|
GamepieceId INT,
|
||||||
|
FOREIGN KEY (GamepieceId) REFERENCES Gamepiece(Id),
|
||||||
|
Language VARCHAR(3) NOT NULL,
|
||||||
|
ReleasedAt DATETIME NOT NULL,
|
||||||
|
Reprint BOOLEAN NOT NULL,
|
||||||
|
SetId INT NOT NULL,
|
||||||
|
FOREIGN KEY (SetId) REFERENCES Set(Id), -- TODO: Set table
|
||||||
|
CollectorNumber VARCHAR(10) NOT NULL,
|
||||||
|
Rarity ENUM("common", "uncommon", "rare", "special", "mythic", "bonus") NOT NULL,
|
||||||
|
ArtistId INT NULL,
|
||||||
|
FOREIGN KEY (ArtistId) REFERENCES Artist(Id), -- TODO: Artist table
|
||||||
|
BorderColor ENUM("black", "white", "borderless", "silver", "gold") NOT NULL,
|
||||||
|
Frame ENUM("1993", "1997", "2003", "2015", "future") NOT NULL,
|
||||||
|
FullArt BOOLEAN NOT NULL,
|
||||||
|
Textless BOOLEAN NOT NULL,
|
||||||
|
StorySpotlight BOOLEAN NOT NULL,
|
||||||
|
FlavorName VARCHAR(40) NULL, -- TODO: check length
|
||||||
|
FlavorText VARCHAR(300) NULL, -- TODO: check length
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue