Foreign Keys Referencing Tables in Another Database Schema
Yes, MySQL allows defining a foreign key constraint that references a table in a different database schema, as long as both tables use the InnoDB storage engine and meet all foreign key requirements.
Both databases must exist at the time the constraint is created.
Both tables must use the InnoDB engine.
The referenced column must be indexed by a PRIMARY KEY or UNIQUE key.
The referencing (child) column must have a compatible data type and length.
You must include the full schema name in the REFERENCES clause.
Dropping a database that contains referenced tables is not allowed unless the foreign key is removed.
Cross-schema foreign keys behave the same as same-schema foreign keys (CASCADE, SET NULL, RESTRICT, etc.).
Cross-database foreign keys are commonly used in multi-schema designs but require careful management during schema migrations or database drops.