Skip to content

Schema for Streak and learned word page

Sanskar Lamsal edited this page Jul 14, 2024 · 2 revisions

STREAK TABLE

Thought Process:

This table is created with a motive of only showing the users current streak and the highest streak he/she has achieved to the user.

QUERY

CREATE TABLE user_daily_streaks ( id SERIAL PRIMARY KEY, user_id UUID NOT NULL, streak_start_date DATE NOT NULL, streak_end_date DATE, current_streak INT DEFAULT 0, longest_streak INT DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, CONSTRAINT fk_user FOREIGN KEY(user_id) REFERENCES auth.users(id) );

IMAGE

image

FLASHCARD HISTORY FOR USER

Thought Process:

Each user will have some flashcard they have seen and some they have learned. This table stores seen words and learned words as a list of texts so that we could create targeted features with these data.

QUERY

CREATE TABLE user_flashcards ( id SERIAL PRIMARY KEY, user_id UUID NOT NULL UNIQUE, words_not_seen TEXT[] DEFAULT '{}', words_learned TEXT[] DEFAULT '{}', last_viewed TIMESTAMP, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES auth.users(id) );

IMAGE

image

Clone this wiki locally