Back

Query on relationship

  • 1
  • Databases
  • General
  • Cloud
Said Hasyim
16 Jul, 2024, 11:18

Hello, May I seek your opinion on the relationship type to use?

Consider the following data:

  • product A, B, C
  • product group A, B, C

Product group A contains product A, B Product group B contains product A, C Product group C contains product B, C

I am experimenting with one-way relationship, and on delete cascade.

If I delete product group A, it deletes product A and B. I think this is expected because of the delete cascade.

If I want to keep product A, B when I delete product group A. But I want it to delete the product, when all product groups that hold the product have been deleted, is it something that is possible?

For example, if I delete product group A and B, it should delete product A. Product B and C should not be deleted because they are still held by group B and C.

TL;DR
Developers want to know how to set up relationships to delete products without affecting other groups. Solution: consider setting up conditional deletion triggers or using soft deletes instead of hard deletes.
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