* Fixed and refactored existing code. * Updated database structure (appointment foreign keys need to be null, when the record is a unavailable time period).