How to delete an element from the database and delete everything related together.

I have a task list, and I want to delete a task.


But the task entity is related to the effort effort entity,

Each user enters a daily effort.

Thus, when I eliminate the task, I must eliminate the daily effort for that table.


I'm not quite sure which id to get for delete
and in the assign wanted to indicate that the task id chosen to delete would have to be deleted everything related to that task.

Hi Dina,

The delete action which is there by default can be used to delete the single record from the entity of given primary Id from the records of that entity. To delete the efforts stored against the task Id, you can use advanced SQL as below. I am assuming you are using taskId as a foreign key to store the efforts in the effort entity.


The above query will delete all the efforts sorted against the given taskId.


Thanks,

Sachin



Please go through this link for better understanding when you design or modify database :

https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Data_Modeling/Entity_Relationships/Delete_Rules

If you set Delete rule for taskeID in effort entity as "Delete" and if you delete task it will automatically delete efforts belong to that task.

You do not need to delete them separately if you design correctly.

Delete

Setting the Delete Rule to Delete guarantees that when a record of the main Entity is deleted, all the associated records in the related Entities are also deleted. This mechanism is commonly known as Cascade Delete.

Sachin Mahawar wrote:

Hi Dina,

The delete action which is there by default can be used to delete the single record from the entity of given primary Id from the records of that entity. To delete the efforts stored against the task Id, you can use advanced SQL as below. I am assuming you are using taskId as a foreign key to store the efforts in the effort entity.


The above query will delete all the efforts sorted against the given taskId.


Thanks,

Sachin



So I need to create a structure, and it will delete only the daily details related to that task?


Abdul quadir Saifee wrote:

Please go through this link for better understanding when you design or modify database :

https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Data_Modeling/Entity_Relationships/Delete_Rules

If you set Delete rule for taskeID in effort entity as "Delete" and if you delete task it will automatically delete efforts belong to that task.

You do not need to delete them separately if you design correctly.

Delete

Setting the Delete Rule to Delete guarantees that when a record of the main Entity is deleted, all the associated records in the related Entities are also deleted. This mechanism is commonly known as Cascade Delete.

I have the effort entity with the task ID
and I have the Task with the idProjeto

When I delete a task I want only the related effort to be eliminated.


Solution

Diana Sousa wrote:

Abdul quadir Saifee wrote:

Please go through this link for better understanding when you design or modify database :

https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Data_Modeling/Entity_Relationships/Delete_Rules

If you set Delete rule for taskeID in effort entity as "Delete" and if you delete task it will automatically delete efforts belong to that task.

You do not need to delete them separately if you design correctly.

Delete

Setting the Delete Rule to Delete guarantees that when a record of the main Entity is deleted, all the associated records in the related Entities are also deleted. This mechanism is commonly known as Cascade Delete.

I have the effort entity with the task ID
and I have the Task with the idProjeto

When I delete a task I want only the related effort to be eliminated.


So make taskid in effort entity as Delete rule as delete. it will delete only those entity records where its delete rule is set as delete.


Solution