-- type common to process and operation
--
po_type {type_id, type_name}
PK {type_id}
AK {type_name}
operation {operation_id, operation_type}
PK {operation_id}
SK {operation_id, operation_type}
FK {operation_type} REFERENCES po_type {type_id}
process {process_id, process_type}
PK {process_id}
SK {process_id, process_type}
FK {process_type} REFERENCES po_type {type_id}
-- operation_process
-- process_operation_no is an integer (1,2,3 ..) for each process_id
--
op_proc {process_id, process_operation_no, operation_id, the_type, duration}
PK {process_id, process_operation_no}
FK1 {process_id, the_type} REFERENCES process {process_id, process_type}
FK2 {operation_id, the_type} REFERENCES operation {operation_id, operation_type}
Notes: PK = primary key
AK = alternate key (use unique constraint/index)
SK = superkey (use unique constraint/index)
FK = foreign key
我在这里允许在此过程中重复操作,但不确定这在您的模型中是否有意义——如果不是简单地删除 process_operation_no 并在 PK 中使用 operation_id。
编辑
在任何地方保留type_id 名称会更好一些;也没有process_operation_no——不允许操作在进程中重复。
po_type {type_id, type_name}
PK {type_id}
AK {type_name}
operation {operation_id, type_id}
PK {operation_id}
SK {operation_id, type_id}
FK {type_id} REFERENCES po_type {type_id}
process {process_id, type_id}
PK {process_id}
SK {process_id, type_id}
FK {type_id} REFERENCES po_type {type_id}
op_proc {process_id, operation_id, type_id, duration}
PK {process_id, operation_id}
FK1 {process_id, type_id} REFERENCES process {process_id, type_id}
FK2 {operation_id, type_id} REFERENCES operation {operation_id, type_id}