in reply to Migrating a 1NF table to multiple 2NF tables
-- I took the liberty of using table aliases as well SELECT a.name, b.title, s.title, b.year FROM artist a, album b, song s WHERE a.id = b.artist_id AND b.id = s.album_id ORDER BY a.name, b.year, b.title, s.title LIMIT 2;
In some databases this can lead to much faster queries as well. In these cases, by not explicitly stating the join order, the query optimiser can step in and decide based on indices and other factors.
Another thing of note is that as of 3.23.44 MySQL does support foreign key relation(finally!) a bit in the InnoDB table type. If you are using MySQL as a relational database I urge, no implore, you to update and use said table types. Without such contraints (and fully functional transaction, but we'll ignore that for now) you're really not even using a relational database. As an added incentive they'll vastly improve the robustness of your application and remove a lot of (what should be) uneccassy work at the application level.(And yes I do froth at the mouth a bit when expounding on the evils of bad, or the lack of, data-integrity checks ;)
To create an InnoDB table in MySQL simply append 'TYPE=INNODB' to all your CREATE TABLE statements.
See here for more details on the syntax and restrictions.CREATE TABLE parent(id INT NOT NULL, PRIMARY KEY (id)) TYPE=INNODB;