diff --git a/highscores_database.sql b/highscores_database.sql index 74dfc59..ae0a0f6 100644 --- a/highscores_database.sql +++ b/highscores_database.sql @@ -17,7 +17,7 @@ CREATE TABLE CategoryGroups( PadLength smallint not null DEFAULT 26, UsernameLength smallint DEFAULT 12, CONSTRAINT UniqueGuildCategoryGroup UNIQUE (GuildId, GroupName), - FOREIGN KEY (GuildId) REFERENCES Guilds(GuildId), + FOREIGN KEY (GuildId) REFERENCES Guilds(GuildId) ON DELETE CASCADE, PRIMARY KEY (GroupId) ); @@ -30,7 +30,7 @@ CREATE TABLE Categories( IsTimeRecord boolean not null DEFAULT false, IsValidated boolean not null DEFAULT true, CONSTRAINT UniqueCategoryInGroup UNIQUE (GroupId, CategoryName), - FOREIGN KEY (GroupId) REFERENCES CategoryGroups(GroupId), + FOREIGN KEY (GroupId) REFERENCES CategoryGroups(GroupId) ON DELETE CASCADE, PRIMARY Key (CategoryId) ); @@ -38,6 +38,6 @@ CREATE TABLE Scores( UserName varchar(30) not null, Score float not null, -- Maybe should have time and int scores?? timestamp type? CategoryId int unsigned not null, - FOREIGN KEY (CategoryId) REFERENCES Categories(CategoryId), + FOREIGN KEY (CategoryId) REFERENCES Categories(CategoryId) ON DELETE CASCADE, PRIMARY KEY (CategoryId, UserName) ); \ No newline at end of file