Index

public.user_course_instance_exercise_service_variables

Description

A variable is a record that an exercise service can save for a specific user that will be available in all the exercises that use the same exercise service in the future. An exercise service could use this for example to remember some data that user has inputted later on – for example it could remember the user’s name or it could remember a link to a picture that the user has uploaded.

Columns

Name Type Default Nullable Children Parents Comment
course_instance_id uuid true public.course_instances The course instance the variable is scoped to. Each variable is only visible in the current course instance to prevent other courses or other course instances from interfering with each other. Either course_instance_id or exam_id must be set.
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 The variable can be alternatively scoped to an exam instead of the exercise service. Either course_instance_id or exam_id must be set.
exercise_service_slug varchar(255) false Identifier for the exercise service type that stored this variable. The same identifier needs to exist in exercise_services.slug for the variable to work.
id uuid uuid_generate_v4() false A unique, stable identifier for the record.
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.
user_id uuid false public.users The user the variable was created for.
variable_key varchar(255) false Key used to set or to access the variable.
variable_value jsonb false The thing being stored.

Constraints

Name Type Definition
no_duplicate_keys_instance UNIQUE UNIQUE NULLS NOT DISTINCT (variable_key, user_id, course_instance_id, exercise_service_slug, exam_id, deleted_at)
user_course_instance_exercise_service_v_course_instance_id_fkey FOREIGN KEY FOREIGN KEY (course_instance_id) REFERENCES course_instances(id)
user_course_instance_exercise_service_variables_check CHECK CHECK (((course_instance_id IS NULL) <> (exam_id IS NULL)))
user_course_instance_exercise_service_variables_exam_id_fkey FOREIGN KEY FOREIGN KEY (exam_id) REFERENCES exams(id)
user_course_instance_exercise_service_variables_pkey PRIMARY KEY PRIMARY KEY (id)
user_course_instance_exercise_service_variables_user_id_fkey FOREIGN KEY FOREIGN KEY (user_id) REFERENCES users(id)

Indexes

Name Definition
no_duplicate_keys_instance CREATE UNIQUE INDEX no_duplicate_keys_instance ON public.user_course_instance_exercise_service_variables USING btree (variable_key, user_id, course_instance_id, exercise_service_slug, exam_id, deleted_at) NULLS NOT DISTINCT
user_course_instance_exercise_service_variables_pkey CREATE UNIQUE INDEX user_course_instance_exercise_service_variables_pkey ON public.user_course_instance_exercise_service_variables USING btree (id)

Triggers

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

Relations

er

Generated by tbls