This example walks through enforcing a unique constraint on multiple columns.
As an example, let’s look at an appointment application for a vet surgery. Each customer has one or more pets. To ensure we don’t enter a customer’s pet twice we want to make sure a pet’s name is unique for that customer. This means the customer Jill can have a pet named Sparkles. Another customer, Bob, can also have a pet named Sparkles, but a customer cannot have more than one pet named Sparkles: Bob cannot have two cats named Sparkles.
Here’s an example schema:
Customers