At the moment I am solving a problem with database design, I will present a simplified scenario of what is happening:
Suppose I have four tables: Equipment, CurrentState, StateValue, StateType with the following schemes:
Equipment
------------
Id (PK),
Name
CurrentState
------------
Id (PK),
EquipmentId (FK) (IX),
StateValueId (FK),
StateTypeId (FK) (IX)
StateValue
------------
Id (PK),
StateTypeId (FK),
Name
StateType
-----------
Id (PK),
Name
A piece of equipment may have several different CurrentStates belonging to different StateTypes, hence a unique index (IX). StateType is basically a state machine, and StateValue contains values for each state machine.
Now my question, as well as two questions, are about the StateTypeId foreign keys in the CurrentState and StateValue tables, which determine that StateType is a CurrentState record and which StateType is a StateValue record.
, ? , , CurrentState StateType , StateValue, CurrentState ( FK StateValue FK)...
: StateTypeId FK CurrentState, , , CurrentState EquipmentId, StateValueIds, StateValue StateType...
CurrentState, ? , . Entity Framework , ( ).