branhoff / hooter-the-tutor

0 stars 2 forks source link

Implement robust SQL database system for streak and user data management #12

Open branhoff opened 1 month ago

branhoff commented 1 month ago

Implement robust SQL database system for streak and user data management

Description

Currently, our streak and user data are managed using a JSON file. To improve scalability, data integrity, and query performance, we need to transition to a robust SQL database system. This will allow for more efficient data management, complex queries, and better data relationships.

Objectives

Tasks

Proposed Schema (Example)

CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    discord_id BIGINT UNIQUE NOT NULL,
    username VARCHAR(255) NOT NULL,
    joined_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE streaks (
    id SERIAL PRIMARY KEY,
    user_id INTEGER REFERENCES users(id),
    current_streak INTEGER NOT NULL DEFAULT 0,
    longest_streak INTEGER NOT NULL DEFAULT 0,
    last_study_date DATE
);

CREATE TABLE study_sessions (
    id SERIAL PRIMARY KEY,
    user_id INTEGER REFERENCES users(id),
    start_time TIMESTAMP NOT NULL,
    end_time TIMESTAMP,
    duration INTERVAL
);

Additional Notes

Definition of Done

branhoff commented 3 weeks ago

Recommendation from N^2: https://buyvm.net/kvm-dedicated-server-slices/