Background
I'm building a Private Chef booking service where you can book a Chef to cook you a custom Menu. I'm having trouble creating a SQL db schema that accurately represents the domain while maintaining data integrity.
Requirements
- Customers create a
Bookingby selecting aChefand aMenuand choose theMenuItemsthey want for eachMenuCourse - A
Chefdefines a set ofMenuItemthat a customer can choose from to create theirBooking - A
Menuis a collection ofMenuCourses. (ex. AMenunamed "Tasting Menu" is a 6 course meal, where eachMenuCoursecosts between $10-20). - A
Chefshould be able to associate theirMenuItemswith multipleMenusandMenuCourses. - A customer
Bookingshould contain theChefthe customer selected along with theMenu(and theMenuItems) that will be served.Bookingprice is determined by theMenuandMenuCourseselections (an appetizer costs less than an entree)
Problem
In my current data model, I have the following issues that I'm not sure how to fix:
- it's possible to create a
BookingwithChef"A", but then have aBookingMenuItemthat references aMenuItemwithChef"B" (all theBookingMenuItemfor aBookingshould belong to the sameChef) - a
Bookingreferences a particularMenu(which I need for pricing, pricing is based onMenuandMenuCourse) however aBookingMenuItemfor thatBookingcould reference a completely differentMenuorMenuCourse
Is it possible to re-design my db schema to fix the integrity problems I'm having? Or do I just have to implement these checks at the application level. Thanks!
