Index

public.page_visit_datum_summary_by_courses

Description

Holds an aggregate of page view stats for a whole course for a given day. Can be also used to count all visitors to a course 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
referrer varchar(1024) true What was the referrer of the visitor. Tells where the visitor came from.
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.
utm_campaign varchar(255) true The campaign name
utm_content varchar(255) true Identifies what was clicked
utm_medium varchar(255) true The type of traffic, such as email or cost-per-click (cpc)
utm_source varchar(255) true The site that sent the traffic like google or facebook
utm_term varchar(255) true The search terms
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_courses_course_id_fkey FOREIGN KEY FOREIGN KEY (course_id) REFERENCES courses(id)
page_visit_datum_summary_by_courses_exam_id_fkey FOREIGN KEY FOREIGN KEY (exam_id) REFERENCES exams(id)
page_visit_datum_summary_by_courses_pkey PRIMARY KEY PRIMARY KEY (id)
pvdsbc_no_duplicate_data UNIQUE UNIQUE NULLS NOT DISTINCT (course_id, exam_id, referrer, visit_date, utm_source, utm_medium, utm_campaign, utm_term, utm_content, deleted_at)

Indexes

Name Definition
page_visit_datum_summary_by_courses_pkey CREATE UNIQUE INDEX page_visit_datum_summary_by_courses_pkey ON public.page_visit_datum_summary_by_courses USING btree (id)
pvdsbc_no_duplicate_data CREATE UNIQUE INDEX pvdsbc_no_duplicate_data ON public.page_visit_datum_summary_by_courses USING btree (course_id, exam_id, referrer, visit_date, utm_source, utm_medium, utm_campaign, utm_term, utm_content, deleted_at) NULLS NOT DISTINCT

Triggers

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

Relations

er

Generated by tbls