How to add a foreign key to a database table

Use the addForeignKey() method of the \Magento\Framework\DB\Adapter\AdapterInterface:

Usage examples from the core:




By default the \Magento\Framework\DB\Adapter\AdapterInterface interface is implemented by the \Magento\Framework\DB\Adapter\Pdo\Mysql class:

See also: