Files
agon/MySQL_docker/highscores_database.sql
T

41 lines
1.4 KiB
SQL

CREATE DATABASE highscores;
use highscores;
CREATE TABLE Guilds(
GuildId bigint unsigned not null,
SubmissionChannel bigint unsigned,
UsernameLength smallint DEFAULT 12,
VerificationChannel bigint unsigned,
PRIMARY KEY (GuildId)
);
CREATE TABLE Groups(
ChannelId bigint unsigned,
GroupId int not null AUTO_INCREMENT,
GroupName varchar(50) not null,
GuildId int not null,
MessageId bigint unsigned,
PadLength smallint not null DEFAULT 26,
Size smallint not null, -- unsure if I like this name. Also unsure belong here or in Category
FOREIGN KEY (GuildId) REFERENCES Guilds(GuildId),
PRIMARY KEY (GroupId)
);
CREATE TABLE Categories(
CategoryId int not null AUTO_INCREMENT,
CategoryName varchar(30) not null,
GroupId int not null,
IsAscending boolean not null DEFAULT true,
IsTimeRecord boolean not null DEFAULT false,
IsValidated boolean not null DEFAULT true,
FOREIGN KEY (GroupId) REFERENCES CategoryGroups(GroupId),
PRIMARY Key (CategoryId)
);
CREATE TABLE Scores(
UserName varchar(30) not null,
Score float not null, -- Maybe should have time and int scores?? timestamp type?
CategoryId int not null,
FOREIGN KEY (CategoryId) REFERENCES Categories(CategoryId),
CONSTRAINT PKScore PRIMARY KEY (CategoryId, UserName) -- i think this means there isnt a column for this key but the key is made up of categoryid and username
);