• Essential. Absolutely essential.

    There's no procedural or application code that will stop someone from updating a table directly if they have permissions, or stop a newly written app from putting bad data in because those application constraints have been ignored or forgotten (or because they're too time consuming to write)

    I cannot think of a case where I've been told that 'the application enforces relationships' and the data is accurate. Every single time I've seen that (and it's been a number of times), there's been garbage data in the database that violates the relationships which should exist.

    Foreign keys also provide performance benefits by giving the optimiser additional information which it can use to generate query plans.

    I can't understand why he claims implementing relationships manually in the application (hence writing code to do so) could possibly be easier or less time consuming than writing a foreign key constraint once.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass