Does the following in MySQL:
alter table TABLE_A
ADD CONSTRAINT fk_id (id) REFERENCES TABLE_B(id)
ON DELETE CASCADE ON UPDATE CASCADE;
do the same as
alter table TABLE_A
ADD FOREIGN KEY (id) REFERENCES TABLE_B(id);
except that it also adds a BTREE index on the relationship? Or do they complement each other?
Both queries are more or less the same, though according to the manual the
FOREIGN KEYshould be present in both queries.The benefit of
CONSTRAINT [symbol]is that you can name the constraint rather than MySQL generating the name for you; this symbol must be unique within the database and can be used to later remove the constraint.Generated symbol names can be seen by checking the table structure after creation: