Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MVP data models for goals, subgoals(benchmarks), tasks. #157

Merged
merged 9 commits into from
Jul 27, 2023
31 changes: 30 additions & 1 deletion src/backend/db/migrations/1_initial-migrations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ CREATE TABLE "student" (
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
email TEXT NOT NULL UNIQUE,
assigned_case_manager_id UUID REFERENCES "user" (user_id) ON DELETE SET NULL
assigned_case_manager_id UUID REFERENCES "user" (user_id) ON DELETE SET NULL,
grade SMALLINT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newest mockups have grade on the student table and on students' pages. Although I forgot to implement it elsewhere. I can either a) remove it for now and let another issue handle it or b) write a todo comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, try to keep a PR self contained that is focused on a specific feature/bug. This field would ideally be in the PR that adds that to the frontend/backend, but since you have already added it here, I will leave it to your discretion if you want to leave it in or remove it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Sometimes I think of something and just toss it in, but I'll try to keep things more self contained from now on.

);

CREATE TABLE "file" (
Expand All @@ -70,12 +71,40 @@ CREATE TABLE "goal" (
goal_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), -- TODO: add index to allow reordering
iep_id UUID REFERENCES "iep" (iep_id),
description TEXT NOT NULL,
category TEXT NOT NULL CHECK (category IN ('writing', 'reading', 'math', 'other')),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE TABLE "subgoal" (
subgoal_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), -- TODO: add index to allow reordering
goal_id UUID REFERENCES "goal" (goal_id),
description TEXT NOT NULL,
instructions TEXT NOT NULL DEFAULT '',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
instructions TEXT NOT NULL DEFAULT '',
instructions TEXT NOT NULL DEFAULT "",

Consistent quotes

Copy link
Contributor Author

@jonahchoi jonahchoi Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this first, and found out that in SQL, single and double quotes actually have different meanings. Single quotes are for string literals, while double quotes are "delimited identifiers", meaning they reference tables or columns.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah - thanks for the info. TIL

target_max_attempts INTEGER, --How many "questions" to administer in a single sitting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depends on the type of subgoal this is - e.g. quantitative vs behavioral.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's one reason I left it as an optional column. But I believe we discussed with Niko that our MVP would focus on one collection type, with plans to add more in the future. Maybe we can brainstorm better options for this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SG. Let's get this PR merged in, and we can update it later.

created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()

-- Different collection types may be added later:
-- collection_type TEXT NOT NULL CHECK (collection_type IN ('attempt', 'behavioral')),
);

CREATE TABLE "task" (
task_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
subgoal_id UUID REFERENCES "subgoal" (subgoal_id),
assignee_id UUID REFERENCES "user" (user_id),
due_date TIMESTAMPTZ NOT NULL
);

CREATE TABLE "trial_data" (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
subgoal_id UUID REFERENCES "subgoal" (subgoal_id),
created_by_user_id UUID REFERENCES "user" (user_id),
-- TODO: Possibly add optional reference to "task"
success_with_prompt INTEGER NOT NULL,
success_without_prompt INTEGER NOT NULL,
notes TEXT,-- Optional depending on type of task
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Potential schema for different collection types:
-- type TEXT NOT NULL CHECK (type IN ('attempt', 'behavioral')) -- enum - type of subgoal
-- data jsonb -- actual data, e.g. attempt_counts etc
Loading