For a school Food Delivery application I am developing, I've been told to use the most accurate ER model that captures as many constraints as possible. In particular, I have decided to enforce a given constraint
"Each order’s food items must be from a single restaurant"
using an aggregation from
Restaurant-FoodItem relationship. However, as the application layer requires to get a
restaurant_id associated to an
Order, what I am currently doing to get
restaurant_id is to join all the way from
Restaurants, following the edges on the ER model.
There was another alternative suggested by my teammate to just put
restaurant_id as an attribute in
Orders to enforce the constraint as well as allow easier more efficient retrieval of
restaurant_id. May I know whether the suggested alternative allows us to enforce the earlier constraint?