【问题标题】:Should I connect all database tables to base user, or just 1?我应该将所有数据库表连接到基本用户,还是只连接 1 个?
【发布时间】:2018-03-06 04:39:56
【问题描述】:

我有一个公司可以订阅的应用程序。公司详细信息保存在公司表上:companyId | name | email | subscriptionType | lastPaid

每个公司的员工表中都有员工:employeeId | name | company

如果我有另一个表,用于 -say- 班次,该班次表是否也应该引用每个班次所针对的公司,还是只引用员工?

shiftStart | shiftEnd | employeeIdshiftStart | shiftEnd | employeeId | company

【问题讨论】:

    标签: mysql database database-design


    【解决方案1】:

    我会选择employeeId(你的第一个例子)

    我们从 Employee 表中知道该员工在哪个公司工作,如果需要,我们会在查询中使用连接来添加公司表。

    将 companyId 添加到班次表中只会引入不必要的错误机会。

    【讨论】:

      猜你喜欢
      • 2015-12-25
      • 1970-01-01
      • 1970-01-01
      • 2011-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-14
      相关资源
      最近更新 更多