Making a composite primary key containing appdate
and chair_idchair
will not solve the problem. If appdate for one entry if 2013-07-05 08:30:00
then it will allow another entry with appdate 2013-07-05 08:31:00
for the same chair id, which is incorrect.
To overcome this, before inserting any entry, you will need to check if there is any appointment whose time is overlapping with the current appointment by a query and then only you should allow insert.
E.g. if the duration of an appointment is 30 mins then, before inserting any appointment, you will have to check whether there is any appointment for the same chair whose time is less than 30 mins of the new appointment time.
TIMEDIFF()
function of mysql may help you in this.