Index

public.chapters

Description

Chapters divide pages of a course. They also have a front page.

Columns

Name Type Default Nullable Children Parents Comment
chapter_image_path varchar(255) true Chapter image path is converted to chapter image url once fetched from database.
chapter_number integer false
color varchar(128) true Color of the chapter in the front page.
copied_from uuid true public.chapters The original chapter record of a copy.
course_id uuid false public.courses public.course_modules Which course this chapter belongs to.
course_module_id uuid false public.course_modules The module the chapter is a part of. If null, the chapter is part of the default module.
created_at timestamp with time zone now() false Timestamp when the record was created
deadline timestamp with time zone true The deadline for all the exercises in the chapter.
deleted_at timestamp with time zone true Timestamp when the record was deleted. If null, the record is not deleted.
front_page_id uuid true public.pages Page which is the front page of the chapter i.e. the page where the students end up when they select a chapter in the course material.
id uuid uuid_generate_v4() false public.chapters public.exercises public.pages A unique, stable identifier for the record.
name varchar(255) false A human readable name of the chapter. Shown in the chapter lists.
opens_at timestamp with time zone true If set, the chapter is closed to students before the timestamp and opens automatically at the given time. Students are informed of the opening time. If null, the chapter is always open.
updated_at timestamp with time zone now() false Timestamp when the record was last updated. The field is updated automatically by the set_timestamp trigger.

Constraints

Name Type Definition
chapters_copied_from_fkey FOREIGN KEY FOREIGN KEY (copied_from) REFERENCES chapters(id)
chapters_course_id_fkey FOREIGN KEY FOREIGN KEY (course_id) REFERENCES courses(id)
chapters_course_modules_course_fkey FOREIGN KEY FOREIGN KEY (course_module_id, course_id) REFERENCES course_modules(id, course_id)
chapters_front_page_id_fkey FOREIGN KEY FOREIGN KEY (front_page_id) REFERENCES pages(id)
chapters_module_fkey FOREIGN KEY FOREIGN KEY (course_module_id) REFERENCES course_modules(id)
chapters_pkey PRIMARY KEY PRIMARY KEY (id)
unique_chapters_chapter_number_course_id_when_not_deleted UNIQUE UNIQUE NULLS NOT DISTINCT (chapter_number, course_id, deleted_at)

Indexes

Name Definition
chapters_pkey CREATE UNIQUE INDEX chapters_pkey ON public.chapters USING btree (id)
unique_chapters_chapter_number_course_id_when_not_deleted CREATE UNIQUE INDEX unique_chapters_chapter_number_course_id_when_not_deleted ON public.chapters USING btree (chapter_number, course_id, deleted_at) NULLS NOT DISTINCT

Triggers

Name Definition
set_timestamp CREATE TRIGGER set_timestamp BEFORE UPDATE ON public.chapters FOR EACH ROW EXECUTE FUNCTION trigger_set_timestamp()

Relations

er

Generated by tbls