数据库设计问题
我使用sql server 2008。我的情况如下。
有一个用户表,其中有用户ID,密码,...其余字段
与保险有关,情况如下
- 登录用户有保险(这里只有一个人)
- 登录用户是已投保且同一用户下还有一名投保(这里有两个人,一个已登录,另一个已投保,是0多关系)
- 登录用户未投保,同一用户下还有一名投保用户。
我的问题是保存登录用户和被保险人的个人数据。我的意思是登录用户和被保险人有相同的数据字段。我的意思是
,如果登录用户和受保人相同,那么个人数据将相同。 (我不想在两个不同的表中重复相同的数据)
如果登录用户和被保险人不同,那么两者的个人数据将不同。
我如何设计数据库表
请帮忙...
im using sql server 2008. my scenario is as follows.
there is a user table, with userid, password, ....rest of the fields
it is something related to insurance, the cases are as follows
- logged-in user is insured (there is only one person here)
- logged-in user is insured and there is one more insured under the same user (there are two persons here, one is logged-in and other is insured, its a 0-many relationship)
- logged-in user is not insured and there is one insured under the same user.
here my problem is in saving the personal data of logged-in user and insured. i mean there are same data fields for logged-in user and insured. i mean
if the logged-in user and insured are same then, the personal data will be same. (i dont want to repeat the same data in two different tables)
if the logged-in user and insured are different, then personal data will be different for both.
how do i design the database tables
please help...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您有一个
Policy
表,包含不同的保单,我将创建一个将User
表链接到Policy
的多对多表表使用各自的 ID。这将允许您只需更新一次用户详细信息,并以您想要的任何方式将策略链接到用户。
对于您的场景:
Assuming you have a
Policy
table, holding different insurance policies, I would create a many-to-many table linking theUser
table to thePolicy
table using their respective IDs.This will allow you to simply update user details once and link policies to users in any way you want.
For you scenarios: