Multiple DB Column validation

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
 
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

No one who can help me? My bad luck.....Please....can someone PLEASE
help me resolve this complex validation.....PLEEEEEEEASE.....I
desperately need a concrete solution.....I am on the verge of losing
my job.......PLEEEEEEASE.......

RON
 
B

Bob Barrows [MVP]

No one who can help me? My bad luck.....Please....can someone PLEASE
help me resolve this complex validation.....PLEEEEEEEASE.....I
desperately need a concrete solution.....I am on the verge of losing
my job.......PLEEEEEEASE.......

You posted a question on a Sunday and expected a solution already? Sorry,
but that's not the way newsgroups "work". You may wish to consider another
means of getting help - perhaps hiring a programmer who will work to your
schedule, rather than appealing to a group of people with their own lives
and schedules to consider before taking time to tackle a considerably
complicated problem.

If nobody has porovided a solution by tonight, I will try to remember to
take a look at it after work today.
 
R

rn5a

You posted a question on a Sunday and expected a solution already? Sorry,
but that's not the way newsgroups "work". You may wish to consider another
means of getting help - perhaps hiring a programmer who will work to your
schedule, rather than appealing to a group of people with their own lives
and schedules to consider before taking time to tackle a considerably
complicated problem.

If nobody has porovided a solution by tonight, I will try to remember to
take a look at it after work today.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Bob, after going through your post (especially the last paragraph), I
can at least breathd a sigh of relief. Thanks a lot for that.

Actually the circumstances I am in prompted me for the follow-up post
though I know that it's quite a complicated task. I guess I am
expecting a bit too much from others & I am extremely SORRY for that.
Looking forward to your......

Thanks once again,

Regards,

RON
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top