我有多个表用于存储我们公司的资产,这些表包括:-
• 车辆
• 服务器
• 件
• 家具
现在对于每个资产我想创建一个查找表存储资产模型,例如在创建新 PC 时,用户将选择模型“Dell vostro 350”等。但是更好的是什么?定义四个查找表(例如 vechicle_model、Server_models、Pc_models、家具模型),或者定义一个查找表并有一个描述其类型的列(type = PC)
问候
我有多个表用于存储我们公司的资产,这些表包括:-
• 车辆
• 服务器
• 件
• 家具
现在对于每个资产我想创建一个查找表存储资产模型,例如在创建新 PC 时,用户将选择模型“Dell vostro 350”等。但是更好的是什么?定义四个查找表(例如 vechicle_model、Server_models、Pc_models、家具模型),或者定义一个查找表并有一个描述其类型的列(type = PC)
问候
Use separate lookup tables, despite the similarity they may appear to have - unless you a) Want to allow someone to store a Dell vostro 350
as the type of furniture, or b) want to have significantly more complex constraints inside the database to prevent such cross-selections being recorded.
In fact, your proposal for a single lookup table is so well known, it's even acquired an acronym of it's own - OTLT, short for One True Lookup Table. If you care to search for it, it's almost always mentioned in the same breath as "anti-pattern" or "beginner mistakes".
这些表是否共享相同的列、约束和物理存储?
请注意,上述条件实际上比乍看之下更难满足。例如,如果出现以下情况,则应将表格分开:
因此,您可能需要将表格分开。
如果您只是打算用于查找,我会选择单表解决方案。
如果您计划根据资产的型号存储有关资产的其他信息,例如车辆是汽油/柴油,或者 PC 是台式机还是笔记本电脑,那么多表解决方案可能会更好。