Answer the question
In order to leave comments, you need to log in
How to design a small database and store days of the week "correctly"?
Hello, I am designing a small service. I will use ORM services. I would like to approach qualitatively the initial definition of entities.
The essence of the service - you can create goals, you can create actions for goals, respectively, actions can be performed either one-time (SingularFrequency), or reusable (SeveralFrequency), if reusable, then you can specify which days.
1. How to correctly design a save choice between two tables?
2. How can I work correctly with the "days of the week"? Create a separate table or store as a list of int values?
I apologize if the questions are a bit inaccurate.
Thanks in advance for your advice.
Answer the question
In order to leave comments, you need to log in
store as a regular date, use functions like
dev.mysql.com/doc/refman/5.5/en/date-and-time-func...
Store as `weekdays` SET('0', '1', '2', '3', '4', '5', '6')
check throughFIND_IN_SET(WEEKDAY(NOW()), `weekdays`) > 0
On the first question - I would do this:
Such a connection allows you to attach several schedules to one action. For one-time jobs, the `weekdays` field is not set. The `nextTime` field is set when the schedule is created and allows you to select all actions to be performed, even if they are overdue. After the action is completed, the `nextTime` field can be set to NULL if `weekdays` is empty, or set the time of the next job execution.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question