From 9c762fb346e35705e4cf28952243296886b555d3 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Fri, 10 Mar 2023 17:56:49 -0500 Subject: [PATCH] Add on delete cascade to sql definition. --- highscores_database.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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