Added table creation sql queries.

This commit is contained in:
Gnarwhal 2021-02-04 10:19:52 -05:00
parent 723cd41487
commit 50c68ef268
Signed by: Gnarwhal
GPG key ID: 0989A73D8C421174
2 changed files with 82 additions and 1 deletions

2
backend/.gitignore vendored
View file

@ -18,7 +18,7 @@ gradlew.bat
.settings/
# Local property file
src/main/resources/application-*.properties
src/main/resources/application-local.properties
# Server Keystore
src/main/resources/achievements-ssl-key.p12

81
sql/CreateTables.sql Normal file
View file

@ -0,0 +1,81 @@
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)
)