Index

public.page_visit_datum_summary_by_pages

Description

Holds an aggregate of page view stats for a given page for a given day. Can be also used to count all visitors to a page if you sum visits from all combinations of columns (including null values).

Columns

Name Type Default Nullable Children Parents Comment
course_id uuid true public.courses If the page belongs to a course, the course that the page belongs to.
created_at timestamp with time zone now() false Timestamp when the record was created.
deleted_at timestamp with time zone true Timestamp when the record was deleted. If null, the record is not deleted.
exam_id uuid true public.exams If the page belongs to an exam, the exam that the page belongs to.
id uuid uuid_generate_v4() false A unique, stable identifier for the record.
num_visitors integer 0 false The number of visitors that visited the page with the given utm parameters
page_id uuid false public.pages The page that was visited
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.
visit_date date false The date that the page was visited

Constraints

Name Type Definition
exam_xor_course_id CHECK CHECK ((num_nonnulls(course_id, exam_id) = 1))
num_visitors_positive CHECK CHECK ((num_visitors >= 0))
page_visit_datum_summary_by_pages_course_id_fkey FOREIGN KEY FOREIGN KEY (course_id) REFERENCES courses(id)
page_visit_datum_summary_by_pages_exam_id_fkey FOREIGN KEY FOREIGN KEY (exam_id) REFERENCES exams(id)
page_visit_datum_summary_by_pages_page_id_fkey FOREIGN KEY FOREIGN KEY (page_id) REFERENCES pages(id)
page_visit_datum_summary_by_pages_pkey PRIMARY KEY PRIMARY KEY (id)
pvdsbp_no_duplicate_data UNIQUE UNIQUE NULLS NOT DISTINCT (page_id, course_id, exam_id, visit_date, deleted_at)

Indexes

Name Definition
page_visit_datum_summary_by_pages_pkey CREATE UNIQUE INDEX page_visit_datum_summary_by_pages_pkey ON public.page_visit_datum_summary_by_pages USING btree (id)
pvdsbp_no_duplicate_data CREATE UNIQUE INDEX pvdsbp_no_duplicate_data ON public.page_visit_datum_summary_by_pages USING btree (page_id, course_id, exam_id, visit_date, deleted_at) NULLS NOT DISTINCT

Triggers

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

Relations

er

Generated by tbls