What is the best way to optimize schema for capturing attendance data

前端 未结 4 676
借酒劲吻你
借酒劲吻你 2021-01-14 13:59

We have a sports training camp which is regularly attended by various teams in the city. We have a session per day spanning 2 hrs(9-11 AM) and the time slots could vary for

4条回答
  •  温柔的废话
    2021-01-14 14:16

    IMHO, having a single row per user per month with a lot of concatenated characters isn't going to be any better than having lots of rows with a single character on it, especially if you're going to have to split that string everytime you want to display the data on another application.

    If you just want to figure out the number of days a user attended your camp, why not create a table specifically for that? Everytime you logged a user's attendance, you would only have to update that table by increasing the number of days that the user had attended. As such, this value would not be calculated on-the-fly and it shouldn't give you any performance issues.

    So, my advice would consist in two tables:

    id | user_id | date | present
    

    and

    user_id | month | attendance
    

    You should have some indexes on the user_id field as well, in order to increase the performance of the system.

    Cheers

提交回复
热议问题