CREATE TABLE location (
    id UUID NOT NULL PRIMARY KEY,
    name VARCHAR UNIQUE NOT NULL,
    address VARCHAR,
    note VARCHAR
);

CREATE TABLE location_owner (
    location_id UUID NOT NULL,
    user_id UUID NOT NULL,
    CONSTRAINT FK_location_id FOREIGN KEY (location_id) REFERENCES location(id) ON DELETE CASCADE,
    CONSTRAINT FK_user_id FOREIGN KEY (user_id) REFERENCES client(id) ON DELETE CASCADE,
    PRIMARY KEY(location_id, user_id)
);

ALTER TABLE gamenight
ADD location_id UUID,
ADD CONSTRAINT FK_location_id FOREIGN KEY (location_id) REFERENCES location(id) ON DELETE SET NULL;