I have 3 entities in my system. Let's call them entity A,B and C. Entity A becomes Entity B, and in turn entity B becomes Entity C. I have to keep copies of all 3 entities.
系统中有3个实体。我们称它们为实体A,实体B和实体c,实体A变成实体B,反过来实体B变成实体c,我必须保留所有3个实体的副本。
My dilemma is how to represent them in a relational data. All 3 entities have similar fields. However, some fields are applicable to some entities and some are not.
我的难题是如何在关系数据中表示它们。所有3个实体都有类似的字段。然而,有些字段适用于某些实体,有些则不适用。
What is the recommended approach in this case. Should I use one table and then make a 'Type' field ? The problem with this approach is that some fields will be empty for soem entities. Or should I create separate tables?
在这种情况下,推荐的方法是什么?我应该使用一个表然后创建一个“Type”字段吗?这种方法的问题是有些字段对于soem实体是空的。还是应该创建单独的表?
Any recommendation on best practice would be greatly appreaciated
任何关于最佳实践的建议都将非常感谢。
1 个解决方案
#1
3
this sounds like the manager -> personnel type of hierarchical design. You may have separate tables for each entities. But if they are of same base type when you want to get list of all people, then you have to union all tables. If you use a hierarchy column with a single table approach then you have to join the table with itself. Consider these two options while choosing one solution. Both are right but have their own difficulties.
这听起来像是经理->的人事类型的分层设计。每个实体可能有单独的表。但是如果它们是相同的基类型当你想要得到所有人的列表时,你必须联合所有的表。如果您使用具有单个表方法的层次结构列,那么您必须将该表与其本身联接起来。在选择一个解决方案时考虑这两个选项。两者都是对的,但都有各自的困难。
#1
3
this sounds like the manager -> personnel type of hierarchical design. You may have separate tables for each entities. But if they are of same base type when you want to get list of all people, then you have to union all tables. If you use a hierarchy column with a single table approach then you have to join the table with itself. Consider these two options while choosing one solution. Both are right but have their own difficulties.
这听起来像是经理->的人事类型的分层设计。每个实体可能有单独的表。但是如果它们是相同的基类型当你想要得到所有人的列表时,你必须联合所有的表。如果您使用具有单个表方法的层次结构列,那么您必须将该表与其本身联接起来。在选择一个解决方案时考虑这两个选项。两者都是对的,但都有各自的困难。