Which option correctly describes the relationship between Restaurant, Menu, and Order classes in a typical system design?
Think about how a restaurant offers menus and customers place orders from those menus.
A Restaurant typically offers multiple Menus (e.g., breakfast, lunch). Each Order is placed for items from a Menu. So, the Restaurant owns Menus, and Orders reference Menu items.
Which class design best supports managing multiple orders simultaneously in a restaurant system?
Consider where orders should be tracked and how menus relate to restaurants.
The Restaurant class should manage its Menus and track all Orders placed. Menus do not own Restaurants or Orders. Orders belong to Restaurants and reference Menu items.
What is the best approach to scale order processing when a restaurant receives thousands of orders per minute?
Think about how to handle many requests without blocking the system.
Using a message queue allows the system to accept orders quickly and process them asynchronously, improving scalability and reliability.
What is the main tradeoff when choosing between storing full Menu item details inside an Order versus storing only references to Menu items?
Consider what happens if the Menu changes after an order is placed.
Storing full Menu details in the Order preserves the exact items ordered even if the Menu changes later, but it duplicates data. Storing references saves space but risks inconsistency.
A restaurant expects to receive 10,000 orders daily. Each order stores 5 menu items on average. Each menu item detail stored in an order requires 1 KB of storage. Estimate the total storage needed for order data for one year.
Calculate daily storage then multiply by 365 days.
Daily storage = 10,000 orders * 5 items * 1 KB = 50,000 KB = 50 MB. Yearly storage = 50 MB * 365 = 18,250 MB = 18.25 GB.