数据库设计:第三个表,与父表和子表相关
我正在为一家银行设计一个 SQL Server 2005 数据库,用于保存与客户(父表)及其投资组合(子表)相关的记录,每个客户都有多个投资组合。到目前为止的表格:
Client (Client_Number PK ...)
Portfolio (Portfolio_ID PK, Client_Number FK ...)
我需要包含一个表格来保存相关第三方(例如基金经理、管理员、发起人等)的记录。第三方是不确定的,并且可能会发生变化,关系类型也是如此。这些关系显然是多对多的,所以我正在考虑如下附加表:
Third_Party (Third_Party_ID PK, Third_Party_Name ...)
Relationship (Relationship_ID PK, Third_Party_ID FK, Client_Number FK ...)
这可以很好地工作,但是,第三方可以与投资组合(子表)以及客户(父表)相关。
例如,客户 1 拥有投资组合 1 和投资组合 2。客户 1 和投资组合 1 链接到发起人 1,但投资组合 2 链接到不同的发起人。
对于上述情况的表格设计最佳实践有什么想法吗?
提前致谢。
I'm designing a SQL Server 2005 database for a bank to hold records relating to clients (parent table) and their portfolios (child table), with each client having multiple portfolios. Tables so far:
Client (Client_Number PK ...)
Portfolio (Portfolio_ID PK, Client_Number FK ...)
I need to include a table to hold records for related third parties (e.g. Fund Manager, Administrator, Promoter etc.). The third parties are undetermined and liable to change, as are the relationship types. The relationships are obviously many-to-many, so I was thinking additional tables as follows:
Third_Party (Third_Party_ID PK, Third_Party_Name ...)
Relationship (Relationship_ID PK, Third_Party_ID FK, Client_Number FK ...)
This would work fine, but, the third parties can be related to Portfolios (child table) as well as Clients (parent table).
For example, Client 1 has Portfolio 1 and Portfolio 2. Client 1 and Portfolio 1 are linked to Promoter 1 but Portfolio 2 is linked to a different Promoter.
Any idea as to best practice for table design for the above situation?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会选择两个附加表:
它将充当两个现有表和“第三方”之间的链接实体。我会避开“关系”表,它看起来像是伪装的元数据。
编辑
好的,如果需要考虑更多关系,那么您可能需要更多的复杂性(但由于我不知道您的数据,我可能会错过一些东西!):
如果这是正确的,那么:
I would go for two additional tables:
Which would act as link entities between the two existing tables and 'ThirdParty'. I would steer clear of the 'Relationship' table which looks like metadata in disguise.
EDIT
OK, if there are further relationships to consider then you may need more complexity (but as I don't know your data I may miss something!):
If this is correct then: