数据库设计——映射关系的疑问
我在设计数据库时遇到困惑。
它是一个基于订阅的应用程序:
一个订阅可以有多个显示设备。
订阅时,系统将要求用户选择所显示的设备之一。
记住这一点,我想出了这样的:
上述方法正确吗?
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:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有足够的信息来回答您的问题。
一个用户可以有多个订阅吗?
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?
为什么 SUBNS_DEVICES 和 USER_SUBNS 之间不是多对多?
Why not a many-many between SUBNS_DEVICES and USER_SUBNS?
用户是否只能选择订阅/设备对 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?