Hi, We have this requirement (simplified version): There are 2 tables

Hi,
We have this requirement (simplified version):
There are 2 tables - Employee, EmployeeTasks. The EmployeeTasks table has a reference to Employee table (employeeId column) and it can have several rows for the same employee. There are columns in EmployeeTasks table which are NON-NULLABLE. Our process produces employee object first and the employee task object would be produced after several hours (or maybe days).
What we need is, we should insert into the Employee table as soon as we have employee object without waiting for employee task object(s). The EmployeeTask can be inserted as and when we get the object populated by our process.

To bring the proper Foreign key constraint between the 2 tables, we added the employeeTask CDT inside the employee CDT. This way the tables get created properly with correct constraints. But, when we try to insert employee (by using Write To DataStore smart service and mapping employeeCDT), we get "cannot insert nu...

OriginalPostID-102760

OriginalPostID-102760

  Discussion posts and replies are publicly visible

Parents
  • ...ll into xyz (non-nullable) column in EmployeeTask" error.

    So, we deleted CDTs and recreated this way - EmployeeCDT doesn't have reference to EmployeeTaskCDT, but EmployeeTaskCDT contains a field called employeeId which is of type EmployeeCDT. This way, again, the DB constrains are established correctly, and we are able to insert into Employee table without facing problem. But when we insert into EmployeeTask we face problem. If we just populate the employeeId in the EmployeeCDT within the EmployeeTaskCDT, all data is getting wiped off in the row in Employee table. Of course we could populate all the fields in EmployeeCDT within the EmployeeTaskCDT, but then everytime we insert into EmployeeTask we would unnecessarily be updating Employee.
    This left us wondering what would be the right way to solve the issue and also meet our requirement. Pls let know your thoughts.
Reply
  • ...ll into xyz (non-nullable) column in EmployeeTask" error.

    So, we deleted CDTs and recreated this way - EmployeeCDT doesn't have reference to EmployeeTaskCDT, but EmployeeTaskCDT contains a field called employeeId which is of type EmployeeCDT. This way, again, the DB constrains are established correctly, and we are able to insert into Employee table without facing problem. But when we insert into EmployeeTask we face problem. If we just populate the employeeId in the EmployeeCDT within the EmployeeTaskCDT, all data is getting wiped off in the row in Employee table. Of course we could populate all the fields in EmployeeCDT within the EmployeeTaskCDT, but then everytime we insert into EmployeeTask we would unnecessarily be updating Employee.
    This left us wondering what would be the right way to solve the issue and also meet our requirement. Pls let know your thoughts.
Children
No Data