Answer the question
In order to leave comments, you need to log in
How to properly design a database for storing tour schedules?
Hello colleagues!
The task at first glance is simple, but if you think about it, a lot of pitfalls pop up.
In general, I am developing a site for the sale of excursion services. I'm not entirely clear about the tour schedule. There is a website (satellite8) where you can add your excursions. There is just such a window:
You can select a date and repeat the date (daily, weekly and monthly). I can't understand how it all works. Let's say I chose 2018.06.02 and chose to repeat weekly, what records will go into the database? What is the structure of the schedule storage table? Not quite clear.
In addition, you need to somehow understand when the tour will be held in the near future (there is a page on which all tours are displayed, and next to each tour it is written when it takes place in the near future)
I am only interested in how to store information about when the tour takes place. How to implement date repetition and how to reflect it in the database? How would you do?
Thanks in advance to anyone who can help or give me some ideas.
Answer the question
In order to leave comments, you need to log in
Why store tons of information that will become irrelevant tomorrow. Keep one record - with the data you listed.
And for a specific day, you make 2 queries to the database. Today there will be excursions that have:
1. Start date - today.
2. Start date in the past and:
2.1 repeat - daily
2.2 repeat - weekly and today the same day of the week (the difference in days is a multiple of 7). You can optimize by writing the day in a separate column so you don't have to calculate it every time.
2.2 repeat - monthly and today is the same day of the month. Optimization is also possible.
And that's all. Due to the fact that you will not shove daily records into the table, it will remain small, and it will be quite possible to go through it with such requests without any special brakes.
Naturally, immediately provide for the archiving of outdated excursions. A date flag in the same row or a separate table with one more column (end date) and where obsolete data is dumped.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question