I’m developing a booking system where by certain users can book an Activity for a specific date and time (these times are Activity specific). The system needs to check if that Activity is available at this time (There may be a class being held at that time, for example).
How would I represent the date/times that an Activity can be booked in a Database schema?
Example:
Activity - Swimming Available times: Monday : 9am - 5pm Tuesday : 9am - 12pm Wednesday : 9am - 4pm Thursday : 10am - 3pm Friday : 9am - 5pm
If I have a record in my Activity table for the Swimming activity. Which holds details such as the description, cost etc how would I store this schedule in a field?
Thanks.
I’d suggest you have a separate table for schedules with an int
ScheduleIDprimary key, intActivityIDforeign key, datetimeStartTime, timeIntervaland any other columns it needs.Then, when checking to see if a new activity conflicts with a previously scheduled one, you can use LINQ to SQL:
Disclaimer: Not 100% sure the DataContext will make it work this way.