如何对任务应用程序的关联进行建模?

发布于 2024-11-14 09:24:24 字数 685 浏览 2 评论 0原文

我正在开发一个目标完成应用程序,其中可以有目标、里程碑和任务。里程碑属于目标,目标可以有许多里程碑,任务可以属于目标、里程碑,也可以独立存在。我想要在每个模型中存储的信息如下:

Goal      content:string, est_completion_date:date completed:boolean, completion_date:date
Milestone content:string, est_completion_date:date completed:boolean, completion_date:date 
Task      content:string, occur_on:date completed:boolean, completion_date:date, days:?

任务模型的“occurr_on”字段用于将任务安排在自定义日期。 “天”字段存储任务应该在一周中的哪几天发生(如果任务重复出现)。

我有两个问题。

1)我读到有关单表继承的内容,想知道这是否适合我。每个模型几乎都是相同的,除了任务模型有“days”和“occurr_on”,但没有“est_completion_date”。对所有这些关联进行建模的最佳方法是什么?

2)我不太确定如何最好地存储有关任务应该在一周中的哪几天发生的信息。我应该将其设为一个包含每天布尔值的关联数组,还是应该在表中为每一天设置单独的字段?

I'm working on a goal completion application, where there can be Goals, Milestones, and Tasks. Milestones belong to goals, goals can have many milestones, and tasks can belong to either goals, milestones, or stand on their own. The information I want to store in each model is as follows:

Goal      content:string, est_completion_date:date completed:boolean, completion_date:date
Milestone content:string, est_completion_date:date completed:boolean, completion_date:date 
Task      content:string, occur_on:date completed:boolean, completion_date:date, days:?

The 'occur_on' field for the Task model is to schedule the task for a custom date. The 'days' field stores what days of the week the task should happen, if it's recurring.

I have two questions.

1) I read about single table inheritance and wondered if this would work for me. Every model is pretty much the same except the Task model has 'days' and 'occur_on', but doesn't have 'est_completion_date'. What's the best way to model all of these associations?

2) I'm not quite sure how to best store the information regarding what days of the week a task should occur on. Should I just make it an associative array with boolean values for each day, or should I have separate fields for each day in the table?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戏蝶舞 2024-11-21 09:24:24

1)您的单表继承问题这里得到了很好的解答< /a>.

2) 我建议您的 days 列保持简单。只需存储一串数字,每个数字代表一天。因此 245 可能代表周一、周三和周四。周四。要查找星期三发生的任务,您可以使用正则表达式进行查询,例如 select * fromtasks where days regexp("4");

1) Your single table inheritance question is well answered here.

2) I recommend keeping it simple for your days column. Just store a string of digits, with each digit representing a day. So 245 might represent Monday, Wednesday & Thursday. To find tasks that occur on Wednesday you can query with a regular expression, e.g. select * from tasks where days regexp("4");

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文