Click here to Skip to main content
16,007,885 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Horror, or not? Pin
darkelv26-Feb-08 22:48
darkelv26-Feb-08 22:48 
GeneralRe: Horror, or not? Pin
Vasudevan Deepak Kumar27-Feb-08 1:13
Vasudevan Deepak Kumar27-Feb-08 1:13 
GeneralRe: Horror, or not? Pin
Paul Conrad27-Feb-08 6:41
professionalPaul Conrad27-Feb-08 6:41 
GeneralRe: Horror, or not? Pin
Philip Laureano27-Feb-08 21:52
Philip Laureano27-Feb-08 21:52 
GeneralRe: Horror, or not? Pin
VentsyV10-Mar-08 12:23
VentsyV10-Mar-08 12:23 
GeneralRe: Horror, or not? Pin
Philip Laureano10-Mar-08 18:50
Philip Laureano10-Mar-08 18:50 
GeneralRe: Horror, or not? Pin
Megidolaon18-Jun-08 4:28
Megidolaon18-Jun-08 4:28 
GeneralRe: Horror, or not? Pin
Pete O'Hanlon27-Feb-08 0:39
mvePete O'Hanlon27-Feb-08 0:39 
Enforcing referential integrity takes clock cycles, and this is where you end up getting into a battle with DBAs. A DBA will typically point out that it is up to your application to ensure integrity, but you argue back that you have the tools in the database to do it - so why not let the database do what it is designed for? In some cases, the DBA has a point because they have a legacy database where the referential integrity checking is a real kludge (i.e. slow). In more modern DBs though, referential integrity is performed much quicker (generally by using a quick index scan).

Now, the issue becomes how to react to a referential integrity problem and this becomes an architectural issue. If you leave it to the database to inform you then you've gone through the whole process of submitting the data and waiting for the database to verify (or not) that the operation has succeeded. If it fails, you have to notify the user/do some remedial work. If your application checks the integrity though, then theoretically this becomes less of an issue. There is a problem with this line of thinking though - you could only guarantee this if the database were single user; in the time between you performing the check and you actually attempting the insert (or update), the record could have been deleted at which point you've broken the integrity rules. Another issue boils down to this - if you leave it to your code to check the integrity then EVERY update/insert/delete statement must check the integrity (and in the case of deletes this can be across multiple tables - which means your selects must be redone everytime a new table is added into the referential mix).

Bottom line - the DB provides the tools to do this. It's efficient, and means you don't have to worry about forgetting to perform a referential check.


Deja View - the feeling that you've seen this post before.

My blog | My articles



GeneralRe: Horror, or not? Pin
Vasudevan Deepak Kumar27-Feb-08 1:15
Vasudevan Deepak Kumar27-Feb-08 1:15 
GeneralRe: Horror, or not? Pin
Expert Coming27-Feb-08 5:51
Expert Coming27-Feb-08 5:51 
GeneralRe: Horror, or not? Pin
leppie28-Feb-08 3:51
leppie28-Feb-08 3:51 
GeneralRe: Horror, or not? Pin
Expert Coming28-Feb-08 12:27
Expert Coming28-Feb-08 12:27 
GeneralRe: Horror, or not? Pin
PIEBALDconsult27-Feb-08 6:48
mvePIEBALDconsult27-Feb-08 6:48 
GeneralRe: Horror, or not? Pin
Pete O'Hanlon27-Feb-08 9:24
mvePete O'Hanlon27-Feb-08 9:24 
GeneralRe: Horror, or not? Pin
PIEBALDconsult27-Feb-08 15:51
mvePIEBALDconsult27-Feb-08 15:51 
GeneralRe: Horror, or not? Pin
User 274316227-Feb-08 22:48
User 274316227-Feb-08 22:48 
GeneralRe: Horror, or not? Pin
leppie28-Feb-08 3:32
leppie28-Feb-08 3:32 
GeneralRe: Horror, or not? Pin
Pete O'Hanlon28-Feb-08 4:10
mvePete O'Hanlon28-Feb-08 4:10 
GeneralRe: Horror, or not? Pin
leppie28-Feb-08 5:14
leppie28-Feb-08 5:14 
GeneralRe: Horror, or not? Pin
Paddy Boyd27-Feb-08 1:17
Paddy Boyd27-Feb-08 1:17 
GeneralRe: Horror, or not? Pin
Paul Conrad27-Feb-08 6:40
professionalPaul Conrad27-Feb-08 6:40 
GeneralRe: Horror, or not? Pin
Yusuf28-Feb-08 5:04
Yusuf28-Feb-08 5:04 
GeneralRe: Horror, or not? Pin
Dan Neely28-Feb-08 6:58
Dan Neely28-Feb-08 6:58 
GeneralRe: Horror, or not? Pin
PIEBALDconsult28-Feb-08 16:26
mvePIEBALDconsult28-Feb-08 16:26 
GeneralRe: Horror, or not? Pin
AEternal28-Feb-08 11:34
AEternal28-Feb-08 11:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.