DROP TABLE IF EXISTS `Votes`;
DROP TABLE IF EXISTS `UsersInLobbies`;
DROP TABLE IF EXISTS `Users`;
DROP TABLE IF EXISTS `Lobbies`;


CREATE TABLE Users (
    UUID CHAR(16) NOT NULL UNIQUE PRIMARY KEY,
    Name VARCHAR(255) NOT NULL
	-- LobbyID INT NULL,
	-- FOREIGN KEY (LobbyID) REFERENCES Lobbies(ID)
);

CREATE TABLE Lobbies (
    ID INT NOT NULL UNIQUE PRIMARY KEY,
	Public BOOLEAN DEFAULT false
);

CREATE TABLE UsersInLobbies (
	LobbyID INT NOT NULL,
	UserID CHAR(16) NOT NULL UNIQUE,
	FOREIGN KEY (LobbyID) REFERENCES Lobbies(ID),
	FOREIGN KEY (UserID) REFERENCES Users(UUID)
);

CREATE TABLE Votes (
	UserID CHAR(16) NOT NULL UNIQUE,
	GameID INT NOT NULL,
	Ready BOOLEAN DEFAULT FALSE,
	FOREIGN KEY (UserID) REFERENCES UsersInLobbies(UserID)
);