我有以下Deductions
表:
Id IDENTITY(1,1)
CompanyId int
PeriodId int
EmployeeId int
DeductionTypeId int
Amount decimal](12, 2)
PK:Id
唯一索引:CompanyId
,PeriodId
,EmployeeId
,DeductionTypeId
样本数据:
Id CompanyId PeriodId EmployeeId DeductionTypeId Amount
1 1000 1 100 1 500
2 1000 1 100 2 200
3 1000 1 100 3 100
4 1000 1 100 4 330
将其分为具有父子关系的2个表是个好主意吗?
这是为了避免重复的列CompanyId
,PeriodId
,EmployeeId
。
表1:DeductionHdr
Id CompanyId PeriodId EmployeeId
1 1000 1 100
表2:DeductionDtl
DeductionId DeductionTypeId Amount
1 1 500
1 2 200
1 3 100
1 4 330
答案 0 :(得分:0)
公司不应该在“雇员”表中吗?
ID EmployeeId PeriodId DeductionTypeId Amount
1 100 1 1 500
将“金额”字段作为变量以方便将来更改可能会很方便。
答案 1 :(得分:0)
如果您想要最佳设计,则父母/子女是最佳解决方案。
是的,我同意。