开发者

Protect from "double holiday taking" in mysql

Ive got a MySQL-DB which was created like that:

create table vacation 
(
   worker_id smallint not null,
   vacation_start date not null,
   vacation_end date not null,
   primary key (f_actors_id, vacation_start)
); 

Now, my thought was "1 User can only start 1 holiday a day", but I didnt thought of a user taking 4 weeks o开发者_如何学编程f vacation today and then tomorrow. The Database would accept that.

Is there any (not script-side, it should be mysql-side)-Method to say "use that field, only if no other previous holidays are inbetween those dates?"?

Thanks!


Use a trigger before insert or update.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜