MySQL unique constraint over two column that are in different tables

59 Views Asked by At

First I have one table Device that have id, account_id and name .That table has unique constraint over its two column(account_id, name) , meaning we can only have same name if account_ids are different.

Now I split it into two tables Device(id, account_id, profile_id) and Profile (id, name). My question is how I can apply unique constraint as before. I don't allow same profile name with the same account_id. How can I do that in MySql(5.5)? I think I need unique constraint over two tables. Is it possible?

0

There are 0 best solutions below