Menu

#1 Enforce Foreign Key consistency

open
nobody
None
5
2009-10-10
2009-01-05
No

Using a MySQL database dump downloaded yesterday (Jan 4th), I observe that although the database diagram posted in the Wiki shows PK/FK relationships between many tables, most of these relationships aren't enforceable - at least with my data dump.
For example, there are 154 records in "title_awards" that have "title_id"s that do not have any matching record in "titles".
This breaks the foundational concept of a Foreign Key...
This simple query exposes the problem:
select count(*) from title_awards taw where not exists ( select * from titles t where t.title_id = taw.title_id );

Based on the MySQL dump script, these tables are all still using MyISAM, which of course supports FK *declaratively* and *syntatically* but doesn't actually do anything about that information at runtime.
It's a fairly trivial matter to imagine that there is code that allows the permanent deletion of a Title from the database that does not also remove the Awards-related records... (if I ever stumble upon it, I'll let you know.)

Discussion

  • Ahasuerus

    Ahasuerus - 2009-10-10

    Changed to a Feature Request to enforce Foreign Key relationships.

     
  • Ahasuerus

    Ahasuerus - 2009-10-10
    • labels: 993124 -->
    • summary: title_awards talbe is FK-inconsistent with titles --> Enforce Foreign Key consistency
     
  • Ahasuerus

    Ahasuerus - 2013-02-14

    Changed from FR to Support Request.

     

Anonymous
Anonymous

Add attachments
Cancel