I despise the influence MySQL has had on a whole generation of developers. DHH considers databases to be little more than a glorified hash table. While I don’t like to embed too much of an application into the database and generally eschew stored procedures when they’re not absolutely necessary, I consider database constraints to be as vital as a constitution and integral to keeping the entire system DRY (Don’t Repeat Yourself—Every piece of knowledge must have a single, unambiguous, authoritative representation within a system).
When I added constraints to a table representing an hierarchical account structure, I was shocked to discover that Rails was not loading my test fixtures in sequential order. That’s right, Rails was taking my carefully-ordered YAML file with records ordered such that parent records should always be loaded before their children and attempting to insert records from the middle first, which the database didn’t appreciate due to the constraints I had established.
I can only surmise that Rails is loading the entire YAML file into a hash table in memory before inserting its values—which we all know are not stored sequentially—into the database. This method does not scale to a significant number of records and it is a slap in the face to those who believe in database-enforced referential integrity.
I blame MySQL because its fans turn its vices into virtues and their mindset affects their software in ways that violate the principle of least surprise.
