Changeset c4c43f3


Ignore:
Timestamp:
04/20/26 19:04:21 (3 months ago)
Author:
Andrej <asumanovski@…>
Branches:
master
Children:
37307aa
Parents:
6fa5831
Message:

Normalization of the database

Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • backend/HELP.md

    r6fa5831 rc4c43f3  
    11# Getting Started
     2
     3### Project Documentation
     4
     5* [Normalization (Phase P5)](docs/Normalization.txt)
    26
    37### Reference Documentation
  • backend/src/main/java/com/trekr/backend/entity/discipline/CustomTrackingCategory.java

    r6fa5831 rc4c43f3  
    2828    private String name;
    2929
    30     @Column(name = "num_tasks")
    31     private Integer numTasks;
    32 
    33     @Column(name = "tasks")
    34     private String tasks;
    35 
    3630    public CustomTrackingCategory() {
    3731    }
     
    6054        this.name = name;
    6155    }
    62 
    63     public Integer getNumTasks() {
    64         return numTasks;
    65     }
    66 
    67     public void setNumTasks(Integer numTasks) {
    68         this.numTasks = numTasks;
    69     }
    70 
    71     public String getTasks() {
    72         return tasks;
    73     }
    74 
    75     public void setTasks(String tasks) {
    76         this.tasks = tasks;
    77     }
    7856}
  • backend/src/main/java/com/trekr/backend/entity/discipline/DisciplineUser.java

    r6fa5831 rc4c43f3  
    2424    private User user;
    2525
    26     @Column(name = "num_tasks")
    27     private Integer numTasks;
    28 
    29     @Column(name = "tasks")
    30     private String tasks;
    31 
    3226    public DisciplineUser() {
    3327    }
     
    4842        this.user = user;
    4943    }
    50 
    51     public Integer getNumTasks() {
    52         return numTasks;
    53     }
    54 
    55     public void setNumTasks(Integer numTasks) {
    56         this.numTasks = numTasks;
    57     }
    58 
    59     public String getTasks() {
    60         return tasks;
    61     }
    62 
    63     public void setTasks(String tasks) {
    64         this.tasks = tasks;
    65     }
    6644}
  • backend/src/main/java/com/trekr/backend/entity/training/TrainingSession.java

    r6fa5831 rc4c43f3  
    11package com.trekr.backend.entity.training;
    22
    3 import com.trekr.backend.entity.weight.WeightUser;
    43import jakarta.persistence.Column;
    54import jakarta.persistence.Entity;
     
    2726    @JoinColumn(name = "training_user_id")
    2827    private TrainingUser trainingUser;
    29 
    30     @ManyToOne(fetch = FetchType.LAZY)
    31     @JoinColumn(name = "weight_user_id")
    32     private WeightUser weightUser;
    3328
    3429    @Column(name = "duration")
     
    6358    }
    6459
    65     public WeightUser getWeightUser() {
    66         return weightUser;
    67     }
    68 
    69     public void setWeightUser(WeightUser weightUser) {
    70         this.weightUser = weightUser;
    71     }
    7260
    7361    public BigDecimal getDuration() {
  • db-scripts/ddl.sql

    r6fa5831 rc4c43f3  
    7373    training_user_id BIGINT
    7474        REFERENCES TRAINING_USERS(user_id) ON DELETE CASCADE,
    75     weight_user_id BIGINT
    76         REFERENCES WEIGHT_USERS(user_id) ON DELETE CASCADE,
    7775    duration NUMERIC,
    7876    calories NUMERIC,
     
    8381CREATE TABLE DISCIPLINE_USERS (
    8482    user_id BIGINT PRIMARY KEY
    85         REFERENCES USERS(user_id) ON DELETE CASCADE,
    86     num_tasks INTEGER,
    87     tasks TEXT
     83        REFERENCES USERS(user_id) ON DELETE CASCADE
    8884);
    8985
     
    9288    user_id BIGINT
    9389        REFERENCES USERS(user_id) ON DELETE CASCADE,
    94     name TEXT NOT NULL,
    95     num_tasks INTEGER,
    96     tasks TEXT
     90    name TEXT NOT NULL
    9791);
    9892
  • db-scripts/dml.sql

    r6fa5831 rc4c43f3  
    192192);
    193193
    194 INSERT INTO TRAINING_SESSIONS (training_id, training_user_id, weight_user_id, duration, calories, date, type) VALUES
    195 (1, 1, 1, 60, 500, '2026-02-01', 'Running'),
    196 (2, 2, 2, 45, 400, '2026-02-01', 'Cycling'),
    197 (3, 3, 3, 30, 300, '2026-02-01', 'Swimming'),
    198 (4, 4, 4, 50, 420, '2026-02-02', 'HIIT'),
    199 (5, 5, 5, 40, 350, '2026-02-02', 'Strength'),
    200 (6, 6, 6, 35, 280, '2026-02-02', 'Yoga'),
    201 (7, 7, 7, 55, 520, '2026-02-03', 'Running'),
    202 (8, 8, 8, 45, 390, '2026-02-03', 'Cycling'),
    203 (9, 9, 9, 30, 260, '2026-02-03', 'Rowing'),
    204 (10, 10, 10, 60, 480, '2026-02-04', 'Swimming'),
    205 (11, 11, 11, 50, 430, '2026-02-05', 'Strength'),
    206 (12, 12, 12, 40, 310, '2026-02-05', 'Yoga'),
    207 (13, 13, 13, 60, 540, '2026-02-06', 'Running'),
    208 (14, 14, 14, 35, 260, '2026-02-06', 'Pilates'),
    209 (15, 15, 15, 45, 390, '2026-02-07', 'Cycling'),
    210 (16, 16, 16, 55, 460, '2026-02-07', 'HIIT'),
    211 (17, 17, 17, 30, 240, '2026-02-08', 'Rowing'),
    212 (18, 18, 18, 65, 520, '2026-02-08', 'Swimming'),
    213 (19, 19, 19, 50, 440, '2026-02-09', 'Running'),
    214 (20, 20, 20, 45, 370, '2026-02-09', 'Strength'),
    215 (21, 11, 11, 35, 300, '2026-02-12', 'Cycling'),
    216 (22, 13, 13, 30, 260, '2026-02-12', 'Core'),
    217 (23, 15, 15, 70, 600, '2026-02-13', 'Long Run'),
    218 (24, 17, 17, 40, 320, '2026-02-13', 'Strength');
     194INSERT INTO TRAINING_SESSIONS (training_id, training_user_id, duration, calories, date, type) VALUES
     195(1, 1, 60, 500, '2026-02-01', 'Running'),
     196(2, 2, 45, 400, '2026-02-01', 'Cycling'),
     197(3, 3, 30, 300, '2026-02-01', 'Swimming'),
     198(4, 4, 50, 420, '2026-02-02', 'HIIT'),
     199(5, 5, 40, 350, '2026-02-02', 'Strength'),
     200(6, 6, 35, 280, '2026-02-02', 'Yoga'),
     201(7, 7, 55, 520, '2026-02-03', 'Running'),
     202(8, 8, 45, 390, '2026-02-03', 'Cycling'),
     203(9, 9, 30, 260, '2026-02-03', 'Rowing'),
     204(10, 10, 60, 480, '2026-02-04', 'Swimming'),
     205(11, 11, 50, 430, '2026-02-05', 'Strength'),
     206(12, 12, 40, 310, '2026-02-05', 'Yoga'),
     207(13, 13, 60, 540, '2026-02-06', 'Running'),
     208(14, 14, 35, 260, '2026-02-06', 'Pilates'),
     209(15, 15, 45, 390, '2026-02-07', 'Cycling'),
     210(16, 16, 55, 460, '2026-02-07', 'HIIT'),
     211(17, 17, 30, 240, '2026-02-08', 'Rowing'),
     212(18, 18, 65, 520, '2026-02-08', 'Swimming'),
     213(19, 19, 50, 440, '2026-02-09', 'Running'),
     214(20, 20, 45, 370, '2026-02-09', 'Strength'),
     215(21, 11, 35, 300, '2026-02-12', 'Cycling'),
     216(22, 13, 30, 260, '2026-02-12', 'Core'),
     217(23, 15, 70, 600, '2026-02-13', 'Long Run'),
     218(24, 17, 40, 320, '2026-02-13', 'Strength');
    219219
    220220SELECT setval(
     
    223223);
    224224
    225 INSERT INTO DISCIPLINE_USERS (user_id, num_tasks, tasks) VALUES
    226 (1, 2, '["Morning Run","Read Book"]'),
    227 (2, 1, '["Meditation"]'),
    228 (3, 3, '["Plan Day","No Sugar","Stretch"]'),
    229 (4, 2, '["Drink Water","Walk 8k Steps"]'),
    230 (5, 2, '["Journal","Gym"]'),
    231 (6, 1, '["Study 1h"]'),
    232 (7, 2, '["Stretch 10m","No Soda"]'),
    233 (8, 2, '["Walk 30m","Sleep 7h"]'),
    234 (9, 3, '["Read 20p","Meditate","No Sugar"]'),
    235 (10, 1, '["Drink Water"]'),
    236 (11, 3, '["Morning Run","Plan Day","Study 1h"]'),
    237 (12, 2, '["Yoga","Cook Healthy"]'),
    238 (13, 2, '["Gym","Protein Target"]'),
    239 (14, 2, '["Journal","Early Bed"]'),
    240 (15, 3, '["Duolingo","No Alcohol","Walk 8k Steps"]');
    241 
    242 INSERT INTO CUSTOM_TRACKING_CATEGORIES (custom_tracking_id, user_id, name, num_tasks, tasks) VALUES
    243 (1, 1, 'Project Trekr', 2, '["Code Review","Push Updates"]'),
    244 (2, 2, 'Language Learning', 2, '["Duolingo","Watch Lesson"]'),
    245 (3, 3, 'Side Hustle', 3, '["Client Outreach","Build Feature","Invoice"]'),
    246 (4, 5, 'Fitness Plan', 2, '["Protein Target","Sleep 8h"]'),
    247 (5, 6, 'Exam Prep', 2, '["Practice Problems","Review Notes"]'),
    248 (6, 11, 'University', 3, '["Attend Lecture","Solve Tasks","Review"]'),
    249 (7, 12, 'Health', 2, '["Steps","Water"]'),
    250 (8, 13, 'Startup', 3, '["Pitch","Build","Ship"]'),
    251 (9, 14, 'Cooking', 2, '["Meal Prep","Groceries"]'),
    252 (10, 15, 'Reading List', 2, '["Read Fiction","Read Nonfiction"]'),
    253 (11, 16, 'Work Sprint', 3, '["Standup","Tickets","PR Review"]'),
    254 (12, 17, 'Finance Goals', 2, '["Track Expenses","Invest"]'),
    255 (13, 18, 'Language', 2, '["Duolingo","Podcast"]'),
    256 (14, 19, 'Gym Program', 3, '["Squat","Bench","Deadlift"]'),
    257 (15, 20, 'Exam Prep', 3, '["Practice","Mock","Review"]');
     225INSERT INTO DISCIPLINE_USERS (user_id) VALUES
     226(1),
     227(2),
     228(3),
     229(4),
     230(5),
     231(6),
     232(7),
     233(8),
     234(9),
     235(10),
     236(11),
     237(12),
     238(13),
     239(14),
     240(15);
     241
     242INSERT INTO CUSTOM_TRACKING_CATEGORIES (custom_tracking_id, user_id, name) VALUES
     243(1, 1, 'Project Trekr'),
     244(2, 2, 'Language Learning'),
     245(3, 3, 'Side Hustle'),
     246(4, 5, 'Fitness Plan'),
     247(5, 6, 'Exam Prep'),
     248(6, 11, 'University'),
     249(7, 12, 'Health'),
     250(8, 13, 'Startup'),
     251(9, 14, 'Cooking'),
     252(10, 15, 'Reading List'),
     253(11, 16, 'Work Sprint'),
     254(12, 17, 'Finance Goals'),
     255(13, 18, 'Language'),
     256(14, 19, 'Gym Program'),
     257(15, 20, 'Exam Prep');
    258258
    259259SELECT setval(
Note: See TracChangeset for help on using the changeset viewer.