ERD Description
This Entity-Relationship Diagram (ERD) models a restaurant system, covering key aspects such as users, menu management, stock tracking, orders, and payments. Below is a detailed breakdown of each entity and its relationships.
Entities and Attributes
USERS
- Represents users who place orders (e.g., guests or members).
Attributes:id: Unique identifiername: User's nameemail: User's emailpassword: Encrypted passworduser_type: Role of the user (e.g., GUEST, MEMBER)
- Represents users who place orders (e.g., guests or members).
MENU_ITEMS
- Represents food or beverage items offered.
Attributes:id: Unique identifiername: Name of the menu itemprice: Price per iteminitial_quantity: Initial stock quantitycurrent_quantity: Current available quantitystatus: Availability statuscategory_id: Foreign key referencing CATEGORIES
- Represents food or beverage items offered.
MENU_ITEMS_OPTIONS_GROUP
- Groups related options for menu items (e.g., sauces, toppings).
Attributes:id: Unique identifiername: Group namemenu_item_id: Foreign key referencing MENU_ITEMStype: Type of option group (e.g., required or optional)
- Groups related options for menu items (e.g., sauces, toppings).
MENU_ITEMS_OPTIONS
- Defines individual options (e.g., cheese, extra toppings).
Attributes:id: Unique identifiername: Option nameprice: Price for the option
- Defines individual options (e.g., cheese, extra toppings).
CATEGORIES
- Organizes menu items into categories (e.g., appetizers, drinks).
Attributes:id: Unique identifiername: Category namecover_image: Image representing the category
- Organizes menu items into categories (e.g., appetizers, drinks).
STOCK
- Tracks ingredients available for use in menu items.
Attributes:id: Unique identifieringredient_name: Name of the ingredientavailable_quantity: Quantity available
- Tracks ingredients available for use in menu items.
MENU_ITEM_STOCK
- Links menu items to the stock they require.
Attributes:id: Unique identifiermenu_item_id: Foreign key referencing MENU_ITEMSstock_id: Foreign key referencing STOCKquantity_used: Quantity used per item
- Links menu items to the stock they require.
MENU_ITEM_OPTION_STOCK
- Links options to the stock they require.
Attributes:id: Unique identifieroption_id: Foreign key referencing MENU_ITEMS_OPTIONSstock_id: Foreign key referencing STOCKquantity_used: Quantity used per option
- Links options to the stock they require.
ORDERS
- Represents customer orders.
Attributes:id: Unique identifierorder_date: Date the order was placeduser_id: Foreign key referencing USERStable_id: Table number for the order (nullable for delivery/takeaway)status: Status of the order (e.g., pending, completed)
- Represents customer orders.
ORDER_ITEMS
- Represents the items included in an order.
Attributes:id: Unique identifierorder_id: Foreign key referencing ORDERSmenu_item_id: Foreign key referencing MENU_ITEMSquantity: Quantity orderedtotal_price: Total price for the item(s)
- Represents the items included in an order.
ORDER_ITEMS_OPTIONS
- Links options to items in an order.
Attributes:id: Unique identifierorder_item_id: Foreign key referencing ORDER_ITEMSoption_id: Foreign key referencing MENU_ITEMS_OPTIONSgroup_id: Foreign key referencing MENU_ITEMS_OPTIONS_GROUP
- Links options to items in an order.
BILLS
- Represents bills that consolidate multiple orders.
Attributes:id: Unique identifierbill_date: Date the bill was createdpayment_id: Foreign key referencing PAYMENTS
- Represents bills that consolidate multiple orders.
BILL_ORDERS
- Links orders to bills.
Attributes:id: Unique identifierbill_id: Foreign key referencing BILLSorder_id: Foreign key referencing ORDERS
- Links orders to bills.
PAYMENTS
- Tracks payment transactions.
Attributes:id: Unique identifierpayment_date: Date the payment was mademethod_id: Foreign key referencing PAYMENT_METHODS
- Tracks payment transactions.
PAYMENT_METHODS
- Defines available payment methods (e.g., cash, card).
Attributes:id: Unique identifiermethod: Name of the payment methoddescription: Description of the payment method
- Defines available payment methods (e.g., cash, card).
Relationships
Users and Orders:
- A user can place multiple orders.
(USERS ||--o{ ORDERS)
- A user can place multiple orders.
Orders and Order Items:
- An order contains multiple items.
(ORDERS ||--o{ ORDER_ITEMS)
- An order contains multiple items.
Order Items and Options:
- Order items can have multiple options.
(ORDER_ITEMS ||--o{ ORDER_ITEMS_OPTIONS)
- Order items can have multiple options.
Menu Items and Categories:
- Menu items belong to specific categories.
(MENU_ITEMS }o--|| CATEGORIES)
- Menu items belong to specific categories.
Menu Items and Options Groups:
- Menu items have groups of options.
(MENU_ITEMS }o--|| MENU_ITEMS_OPTIONS_GROUP)
- Menu items have groups of options.
Options Groups and Options:
- Each option group contains multiple options.
(MENU_ITEMS_OPTIONS_GROUP ||--o{ MENU_ITEMS_OPTIONS)
- Each option group contains multiple options.
Stock Management:
- Both menu items and options are associated with stock through MENU_ITEM_STOCK and MENU_ITEM_OPTION_STOCK junction tables.
(MENU_ITEMS }o--o{ MENU_ITEM_STOCK)
(MENU_ITEMS_OPTIONS ||--o{ MENU_ITEM_OPTION_STOCK)
- Both menu items and options are associated with stock through MENU_ITEM_STOCK and MENU_ITEM_OPTION_STOCK junction tables.
Orders and Bills:
- Multiple orders can be associated with a single bill.
(ORDERS }o--|| BILL_ORDERS)
(BILL_ORDERS ||--o{ BILLS)
- Multiple orders can be associated with a single bill.
Bills and Payments:
- Each bill can have one payment record.
(BILLS }o--|| PAYMENTS)
- Each bill can have one payment record.
Payments and Methods:
- Payments use specific methods.
(PAYMENTS }o--|| PAYMENT_METHODS)
- Payments use specific methods.
Summary
This ERD provides a comprehensive model for managing users, menu items, stock, orders, options, bills, and payments in a restaurant system. It ensures:
- Accurate stock management through associations with both menu items and their options.
- Flexible order and billing handling, supporting multiple orders under one bill.
- Granular tracking of options for each order item, with pricing included at the option level.
- Scalable payment processing, allowing multiple payment methods.
This structure supports smooth operations and ensures consistency across all business processes.