如何建模Mutliple多对多的关系,创建一个圈子

发布于 2025-01-23 21:59:07 字数 720 浏览 3 评论 0原文

我正在寻找有关如何为数据库建模的方向。我试图建模的是:我有一个服务列表。每个服务都可以提供给国家列表。该国可能会在该国家使用或可能不会实际使用的每种服务,因此我也需要捕获这一点。

我将其建模为三个表。 Countrestable,可维修和服务_Countriestable。 Services_Countriestable具有用于服务ID,Country ID和IS_BEING_USDE的列,这是该国是否正在使用该服务的AA布尔值。

在应用程序上,用户可以编辑有关该服务的页面,他们可以从复选框列表中选择该服务的国家 /地区。第二个复选框列表,用户可以勾选该国实际使用该服务。

这很好。但是,我被要求在国家 /地区的“全球”中包括一个选项,该选项由多个国家 /地区组成(我还可以看到其他选项被要求添加了相似之处)。因此,用户只能在服务国家 /地区提供全球选择。

这会给Services_Countriestable表造成问题,因为我无法再使用它来跟踪哪些国家实际使用该服务。由于我当前在country_service表(country_id,service_id,is_usis)中存储该价值。但是,如果我在世界范围内介绍,我将无法使用它,因为country_id将用于全球,但是是什么意思?有些国家可能正在使用它,但其他国家可能不会

制作一组四个表(服务,国家 /地区,services_countries_available,services_countries_ususion),但它们都将以一个圆圈加入,这似乎是不正确的。是否有更好的选择来建模?

I am looking for direction on how to model something for a database. What I am trying to model is this: I have a list of Services. Each service can be made available to a list of countries. Each Service, that is avialable to that Country may or may not actually be being used in that country, so I need to capture that too.

I model this as three tables. CountriesTable, ServicesTable and Services_CountriesTable. The Services_CountriesTable has a column for the Services ID, Country ID and Is_Being_Used, which is aa boolean for whether or not the country is using the Service.

On the application, the user can edit a page about the Service and they can pick from a list of check boxes, for Countries that the services is available in. When the pick countries from the available Countries list, the UI then adds those countries to a second list of checkboxes, that the user can tick to say the country is actually using the service.

This works fine. But, I was asked to include an option, in the list of Countries, for "Worldwide" which is comprised of multiple countries (I can also see other options be requested to have added that would be similar). So, the user can just select Worldwide as the countries the Service is available in.

This causes problems for the Services_CountriesTable table, as I can no longer use it to also track which countries are actually using the service. Since I currently store that value in the relationship in the Country_Service table (Country_ID, Service_ID, Is_Using). But, if I introduce Worldwide, I can't use this because the Country_ID would be for Worldwide, but what would Is_Using mean? Some countries might be using it, but others may not

I could make a set of four tables (Services, Countries, Services_Countries_Available, Services_Countries_Using) but they would all be joined in a circle, which doesn't seem right. Is there a better option to model this?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文