82 lines
2 KiB
MySQL
82 lines
2 KiB
MySQL
|
CREATE TABLE [User] (
|
||
|
ID INT IDENTITY(0, 1) NOT NULL,
|
||
|
Email VARCHAR(254) NOT NULL,
|
||
|
Username VARCHAR(32) NOT NULL,
|
||
|
[Password] CHAR(256) NOT NULL
|
||
|
PRIMARY KEY(ID)
|
||
|
)
|
||
|
|
||
|
CREATE TABLE [Platform] (
|
||
|
ID INT IDENTITY(0, 1) NOT NULL,
|
||
|
PlatformName VARCHAR(32) NOT NULL
|
||
|
PRIMARY KEY(ID)
|
||
|
)
|
||
|
|
||
|
CREATE TABLE [Game] (
|
||
|
ID INT IDENTITY(0, 1) NOT NULL,
|
||
|
Name VARCHAR(32) NOT NULL,
|
||
|
Thumbnail VARCHAR(256) NULL
|
||
|
PRIMARY KEY(ID)
|
||
|
)
|
||
|
|
||
|
CREATE TABLE [Achievement] (
|
||
|
ID INT IDENTITY(0, 1) NOT NULL,
|
||
|
GameID INT NOT NULL,
|
||
|
Name VARCHAR(128) NOT NULL,
|
||
|
Description VARCHAR(512) NULL,
|
||
|
Stages INT NOT NULL,
|
||
|
Thumbnail VARCHAR(256) NULL
|
||
|
PRIMARY KEY(ID)
|
||
|
FOREIGN KEY(GameID) REFERENCES [Game](ID)
|
||
|
)
|
||
|
|
||
|
CREATE TABLE [Owns] (
|
||
|
UserID INT NOT NULL,
|
||
|
GameID INT NOT NULL,
|
||
|
PlatformID INT NOT NULL
|
||
|
PRIMARY KEY(UserID, GameID, PlatformID)
|
||
|
FOREIGN KEY(UserID) REFERENCES [User](ID),
|
||
|
FOREIGN KEY(GameID) REFERENCES [Game](ID),
|
||
|
FOREIGN KEY(PlatformID) REFERENCES [Platform](ID)
|
||
|
)
|
||
|
|
||
|
CREATE TABLE [Progress] (
|
||
|
UserID INT NOT NULL,
|
||
|
GameID INT NOT NULL,
|
||
|
AchievementID INT NOT NULL,
|
||
|
Progress INT NOT NULL
|
||
|
PRIMARY KEY(UserID, GameID, AchievementID)
|
||
|
FOREIGN KEY(UserID) REFERENCES [User](ID),
|
||
|
FOREIGN KEY(GameID) REFERENCES [Game](ID),
|
||
|
FOREIGN KEY(AchievementID) REFERENCES [Achievement](ID)
|
||
|
)
|
||
|
|
||
|
CREATE TABLE [IsOn] (
|
||
|
UserID INT NOT NULL,
|
||
|
PlatformID INT NOT NULL
|
||
|
PRIMARY KEY(UserID, PlatformID)
|
||
|
FOREIGN KEY(UserID) REFERENCES [User](ID),
|
||
|
FOREIGN KEY(PlatformID) REFERENCES [Platform](ID)
|
||
|
)
|
||
|
|
||
|
CREATE TABLE [ExistsOn] (
|
||
|
GameID INT NOT NULL,
|
||
|
PlatformID INT NOT NULL
|
||
|
PRIMARY KEY(GameID, PlatformID)
|
||
|
FOREIGN KEY(GameID) REFERENCES [Game](ID),
|
||
|
FOREIGN KEY(PlatformID) REFERENCES [Platform](ID)
|
||
|
)
|
||
|
|
||
|
CREATE TABLE [Rating] (
|
||
|
UserID INT NOT NULL,
|
||
|
GameID INT NOT NULL,
|
||
|
AchievementID INT NOT NULL,
|
||
|
Quality FLOAT NULL,
|
||
|
Difficulty FLOAT NULL,
|
||
|
[Description] VARCHAR(1024) NULL
|
||
|
PRIMARY KEY(UserID, GameID, AchievementID)
|
||
|
FOREIGN KEY(UserID) REFERENCES [User](ID),
|
||
|
FOREIGN KEY(GameID) REFERENCES [Game](ID),
|
||
|
FOREIGN KEY(AchievementID) REFERENCES [Achievement](ID)
|
||
|
)
|