Mysql automatically updating foreign keys
This makes deployments a crap shoot–whether you’re using migrations or a hand-coded SQL upgrade script, you better hope the whole thing applies cleanly, because if your script blows up halfway through, you’re stuck with a schema that is somewhere between versions.Getting back to a deployable state, or even one where you can rerun the fixed upgrade script, means either manually teasing the schema back to the old version, or reverting to a snapshot and starting all over.It is strange that one can ask simple questions about extended events or Hekaton at professional events and conferences without feeling embarrassed, yet nobody likes to ask vital questions about SQL Server primary keys and foreign keys.
For as long as My SQL has been around, and how many countless users have run into this issue, you’d think they’d consider displaying a better error message.If no clustered index is defined on the table, SQL Server creates a clustered index; otherwise, a nonclustered index is created.That said, you can specify that a nonclustered index be created instead of a clustered index, thus overriding the default.After being a happy Postgre SQL user for years, I’ve finally had to use My SQL for the last 6 months.I have to admit, I was starting to think it wasn’t all that bad–that the “My SQL is a toy” line was outdated. Here is my current laundry list of “dammit, My SQL” complaints: ) and, instead of failing, My SQL will blithely commit all existing work in your transaction, create the table, and then let you continue on your merry way.Unfortunately, RDS is awesome, and RDS uses My SQL.I, and many others, are pulling for Amazon to add Postgre SQL support.Again, we need a primary key (id), the title of the book, and the column that will be used as the Foreign Kye (author_id).The author_id column will be a Foreign Key that references the author table's id column (i.e. First, we need to create a simple table for Authors.There are only two columns: a primary key and the author's name Next, we create a simple table for Books.