• <small id='2pnk0'></small><noframes id='2pnk0'>

      <bdo id='2pnk0'></bdo><ul id='2pnk0'></ul>
  • <legend id='2pnk0'><style id='2pnk0'><dir id='2pnk0'><q id='2pnk0'></q></dir></style></legend>
    <i id='2pnk0'><tr id='2pnk0'><dt id='2pnk0'><q id='2pnk0'><span id='2pnk0'><b id='2pnk0'><form id='2pnk0'><ins id='2pnk0'></ins><ul id='2pnk0'></ul><sub id='2pnk0'></sub></form><legend id='2pnk0'></legend><bdo id='2pnk0'><pre id='2pnk0'><center id='2pnk0'></center></pre></bdo></b><th id='2pnk0'></th></span></q></dt></tr></i><div id='2pnk0'><tfoot id='2pnk0'></tfoot><dl id='2pnk0'><fieldset id='2pnk0'></fieldset></dl></div>

      <tfoot id='2pnk0'></tfoot>

        在 MySQL 中存储日历数据

        时间:2023-08-21
      1. <legend id='lwROd'><style id='lwROd'><dir id='lwROd'><q id='lwROd'></q></dir></style></legend>

      2. <small id='lwROd'></small><noframes id='lwROd'>

            <bdo id='lwROd'></bdo><ul id='lwROd'></ul>

                    <tbody id='lwROd'></tbody>
                  <tfoot id='lwROd'></tfoot>
                1. <i id='lwROd'><tr id='lwROd'><dt id='lwROd'><q id='lwROd'><span id='lwROd'><b id='lwROd'><form id='lwROd'><ins id='lwROd'></ins><ul id='lwROd'></ul><sub id='lwROd'></sub></form><legend id='lwROd'></legend><bdo id='lwROd'><pre id='lwROd'><center id='lwROd'></center></pre></bdo></b><th id='lwROd'></th></span></q></dt></tr></i><div id='lwROd'><tfoot id='lwROd'></tfoot><dl id='lwROd'><fieldset id='lwROd'></fieldset></dl></div>
                2. 本文介绍了在 MySQL 中存储日历数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  只是一个关于存储日历数据的快速架构问题.

                  Just a quick architecture question really on storing calendar data.

                  基本上,我有一个租赁服务数据库.在前端,有一个日历显示未来每个日期的可用"或不可用".在后端,用户可以在 jQuery 日历上将任何日期/日期范围设置为可用或不可用(1 或 0).

                  Basically, I have a database of services for rental. On the front end, there is a calendar to show either "Available" or "Unavailable" for every future date. In the back-end the user can set any date/date range to available or unavailable (1 or 0) on a jQuery calendar.

                  我的问题是您将如何将这些数据存储在 mysql 中并在前端检索它?

                  The question I have is how would you go about storing this data in mysql and retrieving it on the front end?

                  可能有所有可用的日期并存储不可用的日期?然后,如果它们再次设置为可用,则删除该日期的记录?

                  Possible have all dates available and store the unavailable dates? Then if they are set to available again, remove the record for that date?

                  干杯,RJ

                  推荐答案

                  可能有所有可用的日期并存储不可用的日期?然后,如果它们再次设置为可用,则删除该日期的记录?

                  Possible have all dates available and store the unavailable dates? Then if they are set to available again, remove the record for that date?

                  是的,我会这样做,除非我不会在租用到期时删除记录 - 您很容易知道租用已过期,因为它是过去的,因此您也会自动保留租用历史记录.

                  Yes, I'd go with that, except I would not remove the record when renting expires - you'll easily know a renting expired because it's in the past, so you automatically keep the history of renting as well.

                  毕竟,可用日期的数量是无限的1,因此如果您反过来(和存储的免费日期),则必须人为地限制支持的日期范围.

                  After all, there is infinite number of available dates1, so you'd have to artificially limit the supported range of dates if you went the other way around (and stored free dates).

                  1 未来.而且,在某种意义上,过去也是如此.

                  1 In the future. And, in some sense, in the past as well.

                  另外,我猜您需要一些额外的信息,以防租用服务(例如租用者的姓名),如果租用由不存在的行表示,则无处存储!

                  Also, I'm guessing you want some additional information in case a service is rented (e.g. name of the renter) and there would be nowhere to store that if renting were represented by a non-existent row!

                  由于租用的粒度是一整天,我觉得你看的数据库结构是这样的:

                  Since the granularity of renting is a whole day, I think you are looking at a database structure similar to this:

                  注意 RENTING_DAY PK 如何自然地防止重叠.

                  Note how RENTING_DAY PK naturally prevents overlaps.

                  或者,您可以放弃 RENTING_DAY 并直接在 RENTING 中设置 START_DATE 和 END_DATE,但这需要明确的范围重叠检查,可能无法理想地扩展.

                  Alternatively, you might ditch the RENTING_DAY and have START_DATE and END_DATE directly in RENTING, but this would require explicit range overlap checks, which may not scale ideally.

                  这篇关于在 MySQL 中存储日历数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将 Redis 数据同步到 MySQL 的最佳策略是什么? 下一篇:SQL Server 中数据库数量的实际限制?

                  相关文章

                  最新文章

                    • <bdo id='RqXD3'></bdo><ul id='RqXD3'></ul>
                  1. <legend id='RqXD3'><style id='RqXD3'><dir id='RqXD3'><q id='RqXD3'></q></dir></style></legend>

                    <small id='RqXD3'></small><noframes id='RqXD3'>

                      <tfoot id='RqXD3'></tfoot>
                      <i id='RqXD3'><tr id='RqXD3'><dt id='RqXD3'><q id='RqXD3'><span id='RqXD3'><b id='RqXD3'><form id='RqXD3'><ins id='RqXD3'></ins><ul id='RqXD3'></ul><sub id='RqXD3'></sub></form><legend id='RqXD3'></legend><bdo id='RqXD3'><pre id='RqXD3'><center id='RqXD3'></center></pre></bdo></b><th id='RqXD3'></th></span></q></dt></tr></i><div id='RqXD3'><tfoot id='RqXD3'></tfoot><dl id='RqXD3'><fieldset id='RqXD3'></fieldset></dl></div>