Quote:
|
Originally Posted by loquin
one possibility:
a users table, containing data specific to a user. Include a user ID field.
A schedules table. UserID, TimeIn, and TimeOut
When retrieving data, group by the userID and the Date, and order by time in.
This way, you aren't limited to any specific number of time blocks in a day. Suppose a user checks in at 8, leaves at 9 for a dentist's appointment, gets back at 11, goes to lunch at 12, returns at 12:30, etc.
Nor are you wasting space.
There will also be various lookup tables (User Type, Charge Codes, etc.) How many and what type would depend on the requirements.
|
Your idea for the schedules table is what I had in mind for a separate log table, so that I could keep track of everyone's actual work hours (to see who has actually been coming in to work and such). This alone would be helpful if I didn't need a way to check a student-tutor's availability to be assigned to someone coming in and asking for help (i.e. Student A comes in needing help in Calculus and we must find a tutor who teaches calculus at the closest time possible to when that student is available).
Hopefully I explained myself a bit better this time around. Your idea was good and it was actually already part of my plan elsewhere in the database.
Just to prevent any future mixups for any other possible repliers, here is a more thorough breakdown of my database design so far:
USERS: user id, last name, first name, username, password, date of birth, phone,and emais
Users consist of Students, Tutors, Staff, Faculty, Assistants, Administrators, everyone
ROLES: role id, role name, role description
Defines the different roles in the system (as mentioned in the previous table)
USER_ROLES: role_id and user_id as the P/FK's
Assigns the roles to the users
COURSES: course id, course subject (such as HST), course number (such as 101), course name (such as American History I)
Courses are the actual classes that are available for tutoring
TUTOR_COURSES: user id and course id as the P/FK's
This table would keep track of all the courses and which tutors are capable of teaching them
TUTOR_STUDENTS: tutor id (user id of the tutor) and student id (user id of the student) P/FK's
This table keeps track of which students are being tutored by which tutor.
STUDENT_COURSES: user id of the student and course id
Keeps track of what classes a student may need assistance in (Many students have needs in more than one class, such as ENG 101 and MTH 220)
APPOINTMENTS: appointment id, tutor id, student id, appointment_in, appointment_out (datetimes), and course id
Keeps track of all appointments (scheduled future appointments, those that are planned before hand instead of just students dropping in for help)
SESSIONS: session id, tutor id, student id, course id, session in , session out (both datetimes)
This keeps track of all actual sessions. The rules of the tutoring center dictate that a tutor must sign in a student before a tutoring session and then sign them when they are complete so that we can keep an accurate count of students that come in at particular days/times/months and any other reporting needs.
LOG: log id, user id, log in, log out (both datetimes)
Basic time tracking table which will be used whenever a user (of the appropriate role, such as Tutor or Staff) logs in and out of the system. This is the basic time-card system for keeping of track when the tutors and staff are actually present.
The only major table(s) of this database left to design is the table which keeps track of a Tutor or Staffperson's weekly availability. I know there has to be a more elegant way of doing it than trying to brute force all the fields in such as monday in, monday out, tuesday in, tuesday out, etc. Plus, this does not take into account the possibility of some tutors or staff members working multiple shifts in a day (such as coming in and working 9am to 12pm on Monday, but then coming back in the evening after class at 4pm and working until 7pm).
Perhaps I should just create a table such as this:
Schedule ID, User ID, Day, Time In, Time Out
And this would allow for the table to have multiple records for the same day and the same student?