建模问题:相互依赖的列表,但可以是专门的条目吗?

发布于 2024-07-20 08:27:23 字数 436 浏览 5 评论 0原文

相信我,在在这里提问之前,我已经对这个问题进行了很多思考,我想我已经找到了解决方案,但我想看看你们在解决我自己的问题之前能想出什么:)

场景:

在该域中,我们有 3 个实体:一家治疗机构、一家美容店和一名员工。 一家美容店可以雇用 0 到多名员工。 现在,一家美容院列出了一份可以为顾客提供的可能治疗方案的清单。 每种治疗都有描述、持续时间和价格。 每个员工都有一个类似的列表,但每个员工都可以专门化每种治疗(不同的价格或持续时间),添加新的治疗或“删除”来自美容店的治疗。

..这对我来说似乎是一个相当普遍的问题,所以我希望有人能想出一些聪明的办法:)

到目前为止,我正在考虑让每个治疗都有一个唯一的ID,然后让员工列表自己插入治疗与商店的 ID 相同。 这些员工待遇将覆盖具有相同 ID 的商店员工待遇。

提前致谢

Trust me, I've put a lot of thought into this problem before asking here, and I think I got a solution, but I'd like to see what you guys can come up with before settling for my own :)

SCENARIO:

In the domain we got 3 entities: A treatment, a beautyshop and an employee. A beautyshop can hire 0 to many employees. Now, a beautysalon has a list of possible treatments it can do for its costumers. Each treatment has a description, a duration and a price. Each employee has a similar list, but each employee can specialize each treatment (different price or duration), add new treatments or "remove" treatments derived from the beautyshop.

.. This seems like a rather common problem to me, so I was hoping someone could come up with something clever :)

So far, Im thinking about letting each treatment have a unique id, and then let the employee list insert treatments by itself which will have the same id as the one from the shop. These employee treatments will then override the shop ones with the same id..

Thanks in advance

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

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

发布评论

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

评论(3

你又不是我 2024-07-27 08:27:23

我们是在谈论问题的客观表示还是问题的数据库表示? 如果它是客观表示,那么专门的治疗应该只是通用治疗的子类

对于问题的关系数据库表示,事情变得有点困难:(

beautyshop ---= employee
beautyshop ---= treatment_type
treatment_type ---= treatment
employee =--= treatment

---= 是一对多,=--= 是多对多)。

但是我们如何获得美容店提供的护理列表呢? 我们没有。相反,我们从所有美容店员工处获取了一份可用的护理列表。 也就是说,如果一家美容店有 0 名员工,则它不提供任何护理服务。

您可以在treatment 表中使用空字段来指示特定员工使用默认属性提供此待遇。 如果特定美容店的治疗类型默认值发生变化,则所有治疗都会更新。

Are We talking about the objective representation of the problem or about the database representation of the problem? If it's the objective representation, than a specialized treatment should just be a subclass of the generic treatment.

With the relational database representation of the problem, things get a bit harder:

beautyshop ---= employee
beautyshop ---= treatment_type
treatment_type ---= treatment
employee =--= treatment

(---= is one to many, =--= is many to many).

But how do We get a list of treatments available in a beautyshop? We don't. Instead We get a list of treatments available from all beautyshop employees. That said, if a beautyshop has 0 employees, it serves no treatments.

You might use null fields in treatment table to indicate that the particular employee serves this treatment with default properties. If the treatment_type's defaults change for particular beautyshop, then all treatments are updated.

似狗非友 2024-07-27 08:27:23

我建议通过添加对 Treatment 类的 parentTreatment 引用来向 Treatments 添加某种继承/专业化机制。 您将拥有一组标准治疗,每个员工都可以选择和自定义它们。
BeautySalon 不会显式存储任何 Treatments,瞬态且易失的 getAvailableTreatments() 方法将迭代关联的 Employees< /code> 并聚合每个 Employee 提供的 Treatments 的父 Treatments

I would suggest adding some kind of inheritance/specialization mechanism to the Treatments by adding a parentTreatment reference to the Treatment class. You would have a set of standard Treatments, and each Employee would be able to select and customize them.
The BeautySalons wouldn't explicitly store any Treatments, a transient and volatile getAvailableTreatments() method would iterate over the associated Employees and aggregate the parent Treatments of the Treatments offered by each Employee.

难得心□动 2024-07-27 08:27:23

为什么同一个ID要进行不同的治疗呢?

我宁愿设置一个“自定义处理”ID。

Why do you want to have different treatments with the same ID?

I'd rather set up a "custom treatment" ID.

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