Hot answers tagged foreign-key
I would suggest NOT to use Designer in creating key constraints or doing any DDL / DML operations. Best is to use T-SQL - much flexible, more options, more powerful and you can automate many things with it. There is a learning curve, but its worth learning TSQL rather than keep using GUI. Also, make sure you are using the latest version of SSMS - sql ...
A semantically appropriate way of expressing this would be: select ... from a where not exists ( select null from b where b.x = a.x) NOT EXISTS uses an anti-semi-join which allows the optimiser to be very responsive to the table and join cardinalities.
Assuming your surrogate keys are auto-incrementing integers marked as primary keys they will be the "rowid" for that table so you can read the last value added for a single insert using SELECT last_insert_rowid(). This operates like scope_identity in other databases. You would need to read each one after each row insert as each will replace record of the ...
For that many-to-many 'relation' table, don't bother to have an id. Simply have PRIMARY KEY(case_id, tag_id), INDEX(tag_id, case_id) Note that one of those works perfectly for one of your SELECTs, the other works perfectly for the other. (Use ENGINE=InnoDB.) To get (tag-1, tag-2, tag-3), use GROUP_CONCAT(). FOREIGN KEYs are optional; I would not ...
Only top voted, non community-wiki answers of a minimum length are eligible