私のDBには単純な1対多の関係があります。対応するクラスは次のとおりです。
class Department
{
int deptId;
int count; //This corresponds to the total number of Employees in a department
List<Employee> employees; //An employee belongs to only one department
}
class Employee
{
int employeeId;
Department dept;
}
count
最新の状態を維持するためにcount
、各CUD
操作に を設定しています。count
従業員を部門に追加/削除するたびに自動的に更新する方法はありますか? (注釈/制限か何か?)