W
W
web_dev2014-04-11 15:52:17
Java
web_dev, 2014-04-11 15:52:17

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.
f5a23cd1e8784918ac768eb332f920cc.png
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

4 answer(s)
S
shagguboy, 2014-04-11
@shagguboy

store as a regular date, use functions like
dev.mysql.com/doc/refman/5.5/en/date-and-time-func...

R
Rsa97, 2014-04-11
@Rsa97

Store as
`weekdays` SET('0', '1', '2', '3', '4', '5', '6')check through
FIND_IN_SET(WEEKDAY(NOW()), `weekdays`) > 0

R
Rsa97, 2014-04-12
@Rsa97

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.

W
web_dev, 2014-04-12
@web_dev

@Rsa97 Still, you misunderstood me a bit. Here, I made a small one. sketch, so it should already be 100% clear. )) Thanks for the tips.
361cdb17f7e242c98af7c9d1f36f6e13.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question