Re: pro- foreign key propaganda?

From: TroyK <>
Date: Thu, 15 May 2008 11:13:59 -0700 (PDT)
Message-ID: <>

On May 15, 4:27 am, "sinister" <sinis..._at_nospam.invalid> wrote:
> I'm supervising the development of a database system with a web interface.
> I had built the DB backend using postgresql.  The guy we hired to take over
> the project from me---I have non-IT duties to attend to---for various
> reasons decided to switch to MySQL and created his own tables (as well as
> redoing the web interface).
> After a conversation involving two tables which I thought ought to be
> connected by a foreign key relationship, I went and checked his DB; I was
> worried that he didn't fully understand the importance of using foreign
> keys.  So I ran mysqldump and then did "grep -i foreign dump.sql" and
> "grep -i references dump.sql."  Nothing!
> So...sent him an email late in the day, stressing that it's important that
> foreign keys be used where possible, that as much of the model
> logic/business logic/whatever should be encoded in the database itself to
> ensure data integrity, and so on.
> What do I do if he gets back to me and says---as I'm sure everyone in his
> position does---"oh, but my PHP code makes sure everything is done right"?
> Not that I don't know what to say, but it would be good to have a pointer to
> an essay or webpage that succinctly explains why you're asking for trouble
> if you don't encode such relationships in the DB itself.
> Sure, I could say, "Your next assignment is to read a book on DB theory, and
> give me a 10 minute summary," but we don't have that much time...
> :-(

You might try comparing the code required to declare the FK in the database (i.e., a one-liner) to the code required to enforce the constraint in PHP. Maybe then he can see which is more likely to contain errors.

TroyK Received on Thu May 15 2008 - 20:13:59 CEST

Original text of this message