0

I've the the following ERD

enter image description here

I want that a customer Klant can only place one order Bestelling per day.

I'm not sure how I can accomplish this, I think that I have to use unique index here. Could someone show me how it is done?

Drago
  • 1,755
  • 3
  • 19
  • 30
  • To some extent, it's about how you want to manage the user experience. That said, in this instance a UNIQUE key on (klantnr,besteldatum) will suffice (it doesn't need to be specified as a 'constraint' as such). For more complex scenarios - where you want to limit data entry to 6 or 24 hours, say - you might look at something like this: http://stackoverflow.com/questions/36270561/how-to-restrict-votes-per-day-by-ip-in-phpmysql-voting/36271685#36271685 – Strawberry May 14 '16 at 11:45

1 Answers1

1

Yes, you can add a unique constraint on the fields klantnr and besteldatum.

alter table bestelling
add constraint un_bestelling unique (klantnr, besteldatum)
ebahi
  • 536
  • 2
  • 7