R
rn5a
A MS-Access DB table has the following 6 columns - TeacherID, ClassID,
VenueID, AvailDate, StartTime & EndTime. The data type of the 1st 3
columns is int whereas the data type of the last 3 columns is Date/
Time. The AvailDate column stores only the date (& not the time) where
as the last 2 columns store only the time (& not the date). Assume
that the 1st record in the DB table is ClassID=1, TeacherID=1,
VenueID=1, AvailDate=5/15/2007, StartTime=7AM & EndTime=8AM. This
means that ClassID=1 has already been booked by TeacherID=1 at
VenueID=1 on 15th May 2007 from 7AM to 8AM.
Now I have to ensure that no conflicts arise when users enter records
in these 6 columns. The conflicts could be the following:
A teacher cannot teach 2 classses on the same date & at the same time
(be it in the same venue or a different venue). For e.g. TeacherID=1
cannot teach ClassID=1 & ClassID=2 on 15th May 2007 from 7AM to 8AM.
Hence if a user wants ClassID=2 to be taught by TeacherID=1 on 15th
May from 7AM to 8AM, he shouldn't be allowed since ClassID=1 will be
taught by TeacherID=1 on 15th May from 7AM to 8AM (as the 1st row
says).
Likewise, one class cannot be taught by 2 teachers on the same date &
at the same time (be it in the same venue or different venues). For
e.g. ClassID=1 cannot be taught by TeacherID=1 & TeacherID=2 on 15th
May 2007 from 9AM to 10AM. Hence if a user wants TeacherID=2 to teach
ClassID=1 on 15th May from 7AM to 8AM, he shouldn't be allowed to
enter this data in the DB table since ClassID=1 will be taught by
TeacherID=1 on 15th May from 7AM to 8AM.
Similarly, one teacher/class cannot be at 2 venues on the same date &
at the same time. For e.g. TeacherID=1/ClassID=1 can't be at VenueID=1
& VenueID=2 on 15th May 2007 from 11AM to 12PM respectively. Hence if
a user wants TeacherID=1 to teach ClassID=1 on 15th May from 7AM to
8AM at VenueID=2, he shouldn't be allowed to enter this data in the DB
table since ClassID=1 will be taught by TeacherID=1 on 15th May from
7AM to 8AM at VenueID=1.
Also if a user wants to add another row in the DB table where
ClassID=1 will be taught by TeacherID=1 at VenueID=1 on 15th May from,
say, 7:15AM to 8:15AM, this row should not be allowed in the DB table
since the time slot from 7AM to 8AM has already been booked by
ClassID=1 (who will be taught by TeacherID=1); So can TeacherID=1 (or
any oother teacher) start teaching from the middle of a session.
I have made a start but am not exactly confident about it. What I did
is compared each Form inout data with the corresponding columns in the
DB using the following WHERE clause in the SQL query:
SELECT.....WHERE ClassID=Request.Form("classid") AND
TeacherID=Request.Form("teacherid") AND
VenueID=Request.Form("venueid") etc.....
If such a record exists in the DB, then the question of inserting it
in the DB doesn't arise only. So far so good but what do I do if such
a record doesn't exist? Compare the ClassIDs; if ClassID exists, then
next compare TeacherIDs but even if ClassID entered by the user
doesn't exist, that record cannot be inserted in the DB. Under such
circumstances, the next validation that needs to be done is to find
out whether the TeacherID posted by the Form is already booked at the
input VenueID data on the input AvailDate date from input StartTime
data to input EndTime data so on & so forth & this becomes very
confusing.
Can someone help me out with this?
Thanks,
RON
VenueID, AvailDate, StartTime & EndTime. The data type of the 1st 3
columns is int whereas the data type of the last 3 columns is Date/
Time. The AvailDate column stores only the date (& not the time) where
as the last 2 columns store only the time (& not the date). Assume
that the 1st record in the DB table is ClassID=1, TeacherID=1,
VenueID=1, AvailDate=5/15/2007, StartTime=7AM & EndTime=8AM. This
means that ClassID=1 has already been booked by TeacherID=1 at
VenueID=1 on 15th May 2007 from 7AM to 8AM.
Now I have to ensure that no conflicts arise when users enter records
in these 6 columns. The conflicts could be the following:
A teacher cannot teach 2 classses on the same date & at the same time
(be it in the same venue or a different venue). For e.g. TeacherID=1
cannot teach ClassID=1 & ClassID=2 on 15th May 2007 from 7AM to 8AM.
Hence if a user wants ClassID=2 to be taught by TeacherID=1 on 15th
May from 7AM to 8AM, he shouldn't be allowed since ClassID=1 will be
taught by TeacherID=1 on 15th May from 7AM to 8AM (as the 1st row
says).
Likewise, one class cannot be taught by 2 teachers on the same date &
at the same time (be it in the same venue or different venues). For
e.g. ClassID=1 cannot be taught by TeacherID=1 & TeacherID=2 on 15th
May 2007 from 9AM to 10AM. Hence if a user wants TeacherID=2 to teach
ClassID=1 on 15th May from 7AM to 8AM, he shouldn't be allowed to
enter this data in the DB table since ClassID=1 will be taught by
TeacherID=1 on 15th May from 7AM to 8AM.
Similarly, one teacher/class cannot be at 2 venues on the same date &
at the same time. For e.g. TeacherID=1/ClassID=1 can't be at VenueID=1
& VenueID=2 on 15th May 2007 from 11AM to 12PM respectively. Hence if
a user wants TeacherID=1 to teach ClassID=1 on 15th May from 7AM to
8AM at VenueID=2, he shouldn't be allowed to enter this data in the DB
table since ClassID=1 will be taught by TeacherID=1 on 15th May from
7AM to 8AM at VenueID=1.
Also if a user wants to add another row in the DB table where
ClassID=1 will be taught by TeacherID=1 at VenueID=1 on 15th May from,
say, 7:15AM to 8:15AM, this row should not be allowed in the DB table
since the time slot from 7AM to 8AM has already been booked by
ClassID=1 (who will be taught by TeacherID=1); So can TeacherID=1 (or
any oother teacher) start teaching from the middle of a session.
I have made a start but am not exactly confident about it. What I did
is compared each Form inout data with the corresponding columns in the
DB using the following WHERE clause in the SQL query:
SELECT.....WHERE ClassID=Request.Form("classid") AND
TeacherID=Request.Form("teacherid") AND
VenueID=Request.Form("venueid") etc.....
If such a record exists in the DB, then the question of inserting it
in the DB doesn't arise only. So far so good but what do I do if such
a record doesn't exist? Compare the ClassIDs; if ClassID exists, then
next compare TeacherIDs but even if ClassID entered by the user
doesn't exist, that record cannot be inserted in the DB. Under such
circumstances, the next validation that needs to be done is to find
out whether the TeacherID posted by the Form is already booked at the
input VenueID data on the input AvailDate date from input StartTime
data to input EndTime data so on & so forth & this becomes very
confusing.
Can someone help me out with this?
Thanks,
RON