Locking data
Locking table information
It is sometimes necessary to prohibit the deletion of some data in a table.

When I worked on a demo for easySite.NET, it was necessary to publish some articles, allowing users to modify article’s texts without allowing the articles deletion... here is the solution I found.
The recipe
The table articles contained already a field id (unique article identifier)
I created a table lock_articles... having only one field article_id which refered the field id of the articles table.
To enable unique article insertion in lock_articles table, The relation between articles and lock_articles is 1 to 1



We insert in lock_articles table all IDs of the articles that we don’t want to be deleted.

Now, prior to deleting any item in the articles table, it is necessary to delete its reference in the lock_articles table, which is accessible only to database administrator.