Skip to content
Advertisement

How to create unique key base on three field?

I have two foreign keys in table:

Also field action

I want to add constraints on these three field, that userId + visitorId + action will be unique.

How to do that in Workbench, MYSQL?

Advertisement

Answer

You can create a unique constraint:

You can also do this by creating a unique index:

You should be able to create an index through the Workbench GUI interface.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement