数据库设计——映射关系的疑问

发布于 2024-09-17 01:09:19 字数 295 浏览 4 评论 0原文

我在设计数据库时遇到困惑。

它是一个基于订阅的应用程序:

一个订阅可以有多个显示设备。

订阅时,系统将要求用户选择所显示的设备之一。

记住这一点,我想出了这样的:

alt text

上述方法正确吗?

USER_SUBNS.DISP_DEV_CD(外键)应该引用DISPLAY_DEVICES.DISP_DEV_CD还是SUBNS_DEVICES.DEV_CD?

I am having confusion in designing the database.

Its a Subscription based application :

One Subscription can have multiple display devices.

While Subscribing, the user will be asked to select one of the displayed devices.

Keeping this in mind, I've come up like this:

alt text

Is the above approach correct?

Should the USER_SUBNS.DISP_DEV_CD(foreign key) refer to DISPLAY_DEVICES.DISP_DEV_CD or SUBNS_DEVICES.DEV_CD?

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

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

发布评论

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

评论(3

作业与我同在 2024-09-24 01:09:19

没有足够的信息来回答您的问题。

一个用户可以有多个订阅吗?

Display_Device 表是实际设备(例如我手中的 iPhone)的列表,还是只是类型?

如果显示设备是用户拥有的单独项目,那么用户和设备之间就有一对多。

如果一名用户可以拥有多个订阅,那么您的用户和订阅就具有一对多的关系。如果每个订阅都可以有多个显示器,并且每个显示器可以属于多个订阅,那么显示器和订阅之间就有多对多的情况。

_不是你的问题,但是......

你为什么使用 varchars 来进行 PK?

Not nearly enough information to answer your question.

Can a User have more than one Subscription?

Is a Display_Device table a list of actual devices like The iPhone in my hand, or just types?

If Display Devices are individual items that are owned by users then you have a 1 - many between users and devices.

If a user can have more than one subscription then you have a one to many with Users and Subscriptions. If each subscription can I have more than one display and each display can be in more than one subscription then you have a many to many between displays and subscriptions.

_not to your question but...

And why are you using varchars for your PKs?

旧故 2024-09-24 01:09:19

为什么 SUBNS_DEVICES 和 USER_SUBNS 之间不是多对多?

Why not a many-many between SUBNS_DEVICES and USER_SUBNS?

逆流 2024-09-24 01:09:19

用户是否只能选择订阅/设备对 SUBNS_DEVICES?如果是这样,为什么没有从 USER_SUBNS 到 SUBNS_DEVICES 的引用?

Are users limited to choosing Subscription/Device pairs SUBNS_DEVICES? If so, why no reference from USER_SUBNS to SUBNS_DEVICES?

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