Avoid direct database updates Nov08 '07

As a developer with access to databases that are tied to applications, I have the ability to perform updates directly against the database, without going through any front-end GUI.

This is a dangerous habit to get into.

Although you have access, and the skills to perform direct database updates, it should never be done under normal circumstances, unless proper cascading is built in.

Database tables contain relationships and arrangements amongst each other, where deleting a record from one table could have a direct effect on another table. In a worst case scenario, it could create broken relationships and orphan records, disrupting application-flow and damaging database integrity.

Front-end scripts (web pages, applications, etc) typically have cascading coded in, so the database integrity remains intact.

An example would be a collection of order tables. One table holds the order header information. Another holds the order lines information. And a third holds the order costs information.

To the front-end users, it all appears as one entity. To the database administrators, it's actually three separate entities.

If you run a script directly against the database, deleting a record from the order header table, you still have relationships to that order header present in the lines and costs tables. A good way to handle this would be to write some sort of routine (such as a trigger) that automatically cascades your deletion to the appropriate tables.

Unless this architecture is built-in, it's wise to avoid direct database updates altogether.

Categories: Databases , Development , Tips

Add Feedback (view all)

Leave feedback

Feedback

Input format: The editor controls below will assist with Markdown syntax.

Status

Sub-status

Your info

matthom is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago. Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.

Contact Matt

Similar Entries

Stats

1 unique visit since August 2008

Syndicate

Advertisements