CREATE TABLE `transaction_payees` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `transaction_id` int(10) unsigned NOT NULL, `user_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `unique_user_for_transaction` (`transaction_id`, `user_id`), KEY `transaction_id` (`transaction_id`), KEY `user_id` (`user_id`), CONSTRAINT `transaction_payees_transaction_id` FOREIGN KEY (`transaction_id`) REFERENCES `transactions` (`id`), CONSTRAINT `transaction_payees_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;