Hi.

On Sat 2002-12-28 at 08:15:58 -0500, [EMAIL PROTECTED] wrote:
[...]
>   create table schedule
>   (
>     # ID number
>     id smallint not null default 0 auto_increment primary key ,
>     client smallint , # references client.id
>     class smallint ,  # references classtypes.id
>     place smallint ,  # references places.id
>     instr smallint ,  # references personnel.id
>     time datetime     # when

Don't you need some kind of duration? Or are the times fixed and you
know beforehand when the class starting at x o'clock will end? And
saving a number for the time slot would also work?

>   ) ;
> 
> I could, for every insert, check
> 
>   select * from schedule where client = '1' and time = '...' ;
> 
> to make sure the client isn't being booked twice, or
> 
>   select * from schedule where instr = '1' and time = '...' ;
> 
> to make sure the instructor isn't double-booked, but 

In the case of time slots, you could create a unique index on
(client,time) and (instr,time) and skip the selects. Simply insert and
check for an duplicate key error.

> that seems like it would get awfully slow as the table grows...

I wonder why you think so. Maybe I do not understand your concern
correctly, but with the right indexes this shouldn't be slow. Do I
miss something?

If not: Whether an index (client,time) or (time,client) is better
depends on your data (few or a lot of client, etc). If you don't have
time slots, even (client) or (time) would help, although not as much.

I you are not sure, simply build all of them and look which one get
used. Then dropped the other ones again. The same applies for "instr".

> Is this the sort of thing where a temporary table is advised, or
> should I define a reverse table that shows each instructor and
> his/her bookings, or what?

I am not sure how a temporary table would improve things. So we have
some kind of misunderstanding. Could you post how you would use
temporary tables here? Then I could easier tell, how I would do the
same.

HTH,

        Benjamin.

-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to