dsilhx5830 2014-12-27 22:14
浏览 109

MySQL:关于矩阵的结构解决方案

I have the following UI:

enter image description here

The goal is that an organiser can enter a recurrent activity for the entire year, and the organiser can decide to select which weekdays are applicable for the recurrent event.

My database has a regular structure:

activity_id  |  start_date  |  end_date 

For a one-time event, this is perfect. Even for a date range of three weeks, it's still fine.
However, for a year, it means that there can be hundreds of intervals (records) that need to be inputted into the database in a single save.

I am not confident that this is a good solution, can you give me some advice on the matter?

  • 写回答

1条回答 默认 最新

  • dongxilan9351 2014-12-28 00:12
    关注

    If you are worrying about data load, my suggestion would be to modify your structure above to record which day(s) of the week an event occurs on: activity_id | start_date | end_date | days_of_week and only have one row in the DB for that event. Then, I would create a "blacklist" table, so if a user decides the event won't occur on specific days and "deletes" that occurrence in the UI, it's not removing an occurrence but actually adding a blackout day to another table. Then you can programmatically remove occurrences from your UI based on rows in the blacklist table. Hope this makes sense, let me know if you need clarification.

    评论

报告相同问题?

悬赏问题

  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 如何提取csv文件中需要的列,将其整合为一篇完整文档,并进行jieba分词(语言-python)
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置