diff --git a/backend/.gitignore b/backend/.gitignore index eaa6b6f..ef5b413 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -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 diff --git a/sql/CreateTables.sql b/sql/CreateTables.sql new file mode 100644 index 0000000..a705e57 --- /dev/null +++ b/sql/CreateTables.sql @@ -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) +)