samedi 30 mai 2015

Prevent Inconsistent Database After Delete

I have a table Users, Licenses and Programs. The Licenses table consists of the primary key of Users and Programs.

When I have a user entry in Users and Licenses as well deleting the entry in Users will not delete the Licenses entry hence leaving the database in an inconsistent state: A user identifier still is referenced but the user does not exist.

How would I go about implementing the automatic delete on cascade? I tried adding ON DELETE CASCADE to the definition of the Licenses table and to the delete statement itself but nothing happened.

Shouldn't this be the default behavior?

Note: I'm using SQLite JDBC.

Aucun commentaire:

Enregistrer un commentaire