views:

44

answers:

0

Hi all,

I think I have the use of reference constraints in RDBMS's a bit mixed up.

Take this example for instance:

  • Table folder
  • Table file (with FK_folder)

A file record is a child of a folder record.

When I want a user to delete a folder I want to warn them if there are files located in the folder.

Usually I would therefor put a delete constraint on FK_folder. But the more I think about it, the more I think this is bogus, isn't it? Cause this would defeat the purpose cascading operations, doesn't it?

I should only first test if the folder record has child file records, warn the user, and if the user agrees to delete, go ahead and delete the folder record, allowing it to cascade delete the file records.

I need some reassurance on whether this last assumption is correct. Is it?

Thanks in advance!

related questions