Optimization of database design

id    user_id    time    type    parent_id
1     1          1       w       -1
2     1          2       w       -1
3     1          3       w       -1
4     1          4       w       -1     
5     1          5       w       -1
6     1          6       w       -1
7     1          7       w       -1
8     1          0       h       1
9     1          1       h       1
10    1          2       h       1
11    1          3       h       1
12    1          4       h       1
13    1          5       h       1
14    1          6       h       1

time type is divided into: w (week) h (hours)

time of type w does not have a parent id, hour has a parent id, belongs to the corresponding day of the week

can the design of database tables be optimized?

Jul.20,2021

look at the requirements. A week can correspond to N hours, which belongs to an one-to-many relationship. Why not divide it into two data tables, one table on Monday and one table per hour. Isn't it clean?

Menu