Back

Best practice for downwards cascade

  • 0
  • Databases
  • Cloud
amianthus
13 Mar, 2025, 21:21

Suppose I have the database: Books -> Chapters -> Pages And I want to be able to delete a book's chapter, and then cascade the pages in that chapter along side it but NOT the other way, If I delete a page i do not want it to delete the chapter it was related to.

Right now I have it setup as on the Chapter it has a one way relation to pages that is on cascade mode, and then on Pages it has another one way relation to Chapters that is on null delete mode

Is this a good idea? I wanted to avoid two-way because it would cascade bidirectionally

TL;DR
Developers just need to set up a one-way relation from Chapter to Pages with cascade mode and another one-way relation from Pages to Chapter with null delete mode in order to achieve the desired cascade behavior. This setup allows for cascading pages when deleting a chapter without affecting the relationship in the opposite direction.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more