CREATE TABLE people (
    id UUID PRIMARY KEY,
    owner_id UUID NOT NULL REFERENCES users (id) ON DELETE CASCADE,
    name TEXT NOT NULL
);


CREATE TABLE face_regions (
    id UUID PRIMARY KEY,
    media_id UUID NOT NULL REFERENCES media (id) ON DELETE CASCADE,
    person_id UUID REFERENCES people (id) ON DELETE SET NULL,
    
    x_min REAL NOT NULL,
    y_min REAL NOT NULL,
    x_max REAL NOT NULL,
    y_max REAL NOT NULL
);

CREATE INDEX idx_people_owner_id ON people (owner_id);
CREATE INDEX idx_face_regions_media_id ON face_regions (media_id);
CREATE INDEX idx_face_regions_person_id ON face_regions (person_id);