我对是否应该合并两张桌子或将它们分开来感到困惑。
许多表:
项目: ............ ItemID(pk)............. ItemName ....... ItemDescription
ItemLike: ..... ItemLikeID(pk)....... ItemID(fk)...... UserID(fk)
ItemBlock: ... ItemBlockID(pk).... ItemID(fk)...... UserID(fk)
ItemFlag: ...... ItemFlagID(pk)...... ItemID(fk)...... UserID(fk)
只有2个表:
项目: ................ ItemID(pk)............. ItemName .... ... ItemDescription
ItemAction: ..... ItemActionID(pk).... ItemID(fk)...... UserID(fk).......... ActionType
前者具有良好的性能但是有很多表,后者是紧凑的,但在查询时速度较慢(检查动作类型)。哪种解决方案更好?
答案 0 :(得分:1)
根据我的观点,第二个选项比第一个选项好得多
1) While querying you will get all data in single query
2) No need to make join different table when getting data from table.
3) Primary key will be in a single column in a table rather than in all tables.
4) Easy to understand and maintain.