I am creating a database for a prayer tracker. There are 5 types of prayer for each day. I have a table called "Types"
id, name
1, Type 1
2, Type 2
3, Type 3
4, Type 4
5, Type 5
I want to save records for each user
against each prayer
type for each day. Below is my structure for tracking
table.
id, type_id (FK of Types), user_id (FK of user table), date (Y-m-d)
I have 500K+ users and for each user there can be max of 5 records against each day. This will be in millions. Basically I want to create an optimized db structure, So it should be faster while doing queries.
- User is login and he should see all records of him/her against each day.
- After 1 year, if there are 5 records against each day then for
500K users, it will be 912,500,000 records. Table will be much
bigger. - No. of users are also increasing day by day.
So In order to optimize the database, what will be best practice for above structure of tracking table?
type_id
column datatype = SET. This allows to store one row per user per day.