CREATE TABLE
    users (id SERIAL PRIMARY KEY, name VARCHAR(255) NOT NULL);

CREATE TABLE
    workouts (
        id SERIAL PRIMARY KEY,
        user_id INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
        created_at TIMESTAMP NOT NULL DEFAULT NOW ()
    );

CREATE TABLE
    cadence_readings (
        id SERIAL PRIMARY KEY,
        workout_id INTEGER NOT NULL REFERENCES workouts (id) ON DELETE CASCADE,
        created_at TIMESTAMP NOT NULL,
        rpm INTEGER NOT NULL,
        CONSTRAINT unique_cadence_reading_per_workout_time UNIQUE (workout_id, created_at)
    );