M
M
Melodic2014-08-28 20:13:55
MySQL
Melodic, 2014-08-28 20:13:55

What is the optimal table structure in this case?

Because The previous question was not correct, I create a new one.
There is an Event model (holiday, fair, etc.).
The event can occur both on the exact date (once), and all the time on certain days of the WEEK (there can be more than one day of the week, for example, the event occurs on Saturdays and Thursdays.).
Those. those that occur on a specific date just have a `date` field of type DATE, and those that occur on certain days have 7 fields (monday,tuesday,wednesday, etc.) of type BOOLEAN. Is it correct to combine all these fields in one table? As for me, it is not correct that an event that occurs on a specific date will have 7 fields empty.
Also, events will need to be selected by date. For example, you need to select today's events (08/28/2014, Thursday). The selection should contain events that occur exactly on August 28, 2014 and events that occur on Thursdays.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xmoonlight, 2014-08-28
@xmoonlight

Event (varchar), date (timestamp), day-of-week (varchar/byte)

S
Sergey Romanov, 2014-08-29
@Serhioromano

Events
- name (varchar)
- description (text)
- month (int) - 1-12 since any holiday is usually tied to a month
- type (tinyint(1)) 0-9 types of event date calculations
- rule (varchar) - rule for calculations.
Now we have types. For example, in the code we define type
This means that it's just monthly on the same date every year. So the steering wheel will be 8 and month 3 we get on March 8 annually.
Count days from the beginning of the month. For example, we need the second Monday in October. So the month will be 10 and the rule is 2:1 where 2 is the number of the week and 1 is the number of the day in the week.
for example several days in one week. Monday and Thursday of the second week of September. So the month will be 9 and the rule is 2:1.4 or from Monday to Thursday 2:1-4 or from Monday to Thursday and Saturday 2:1-4.6
And so on.
Such a scheme can describe any recurring event in a sample for the current month.

A
Alexander Sustavov, 2014-08-29
@takovoy

and what's the problem to create only two fields for each event event and dates. In event event and in dates days of the week on which it occurs or dates, as it is more convenient. Why is there a separate place for each day?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question