I have a barbers table (barberId, first name, last name)
I have a clientele table (clientId, first name, last name)
The barbershop is by appointment only. What tables do I need to create a system where clients can look at a calendar, see which barbers are available, and set appointment with a barber?
The barbers don’t have a set schedule: a barber may have a few hours here and there. Therefore a client must look in the calendar to see availability.
I am using MySQL.
There are too many ways for doing this and it depends on your business requirements. First I would rename
clienteleto justclientsit will be easier to work with, easier pluralization when you set variables and so on.If a barber has 3 hours available, does it mean 3 appointments of 1 hour? What if a certain client needs 2 hours? What would happen in this scenario?
Let’s assume that each one takes 1 hour. You can create a table called
appointments, withappointment_id, barber_id, client_id, start_time, end_time. Appointments can be created by barbers or managers, client_id is set when appointment is booked. If you want to see available slots, you will query DB for any appointment that meetsstart_time, end_timerequirements and doesn’t have aclient_id. You can filter by a specificbarber_idor show all available times and their respective barbers.