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
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.
- Reminder: prepare your wish lists
- Utterz: record and share voice messages
- More thoughts on FriendFeed
Similar Entries
- Google Reader published time useful for Twitter updates (42 recent visits)
- Constant Firefox updates comparable to IE (26 recent visits)
- 100 million forced updates (5 recent visits)
- Private Twitter updates and the workplace (14 recent visits)
- Twordy - get wordy with your Twitter updates! (21 recent visits)
- Customize Brightkite-to-Twitter updates (25 recent visits)
Stats
1 unique visit since August 2008