Natural keys model

Original query:

CREATE TABLE users (
"user" text PRIMARY KEY,
email text NOT NULL UNIQUE
);

-- Hierarchy: course -> part -> chapter
CREATE TABLE courses (
course text PRIMARY KEY
);

CREATE TABLE courses_parts(
part text PRIMARY KEY,
course text NOT NULL REFERENCES courses
);

CREATE TABLE parts_chapters(
chapter text PRIMARY KEY,
part text NOT NULL REFERENCES courses_parts
);

CREATE TABLE users_enrolled_courses (
"user" text NOT NULL REFERENCES users,
course text NOT NULL REFERENCES courses,
enrolled_date date NOT NULL,
PRIMARY KEY ("user", course)
);

-- Actually, this is progress by chapter:
CREATE TABLE users_courses_progress(
"user" text NOT NULL,
course text NOT NULL,
chapter text NOT NULL REFERENCES parts_chapters,
finished boolean NOT NULL,
PRIMARY KEY ("user", course, chapter),
FOREIGN KEY ("user", course) REFERENCES users_enrolled_courses
);