== Relational Mapping - Relational Schema and DDL \\ === Notation - Entities are denoted with capital letters and their attributes are defined (a1, a2, ..., an) where n is the number of attributes the entity has. - Primary keys are denoted with underscore and boldness. - Foreign keys are denoted with asterisk suffixing the attribute. \\ === Relations - Relational Schema **USER**(**__user_id__**, first_name, last_name, email, password, phone) \\ **RESTAURANT_OWNER**(**__user_id*__**(USER)) \\ **DELIVERY_MAN**(**__user_id*__**(USER)) \\ **CUSTOMER**(**__user_id*__**(USER)) \\ **ORDER**(**__order_id__**, **user_id***(USER), order_date, comment, status) \\ **ITEM**(**__item_id__**, image_url, name, price, description) \\ **ORDER_ITEMS**(**__order_id*__**(ORDER), **__item_id__**(ITEM), quantity, total_price) \\ **INGREDIENT**(**__ingredient_id__**, name) \\ **ITEM_INGREDIENT**(**__item_id*__**(ITEM), **__ingredient_id*__**(INGREDIENT), quantity) \\ **DELIVERY_FIRM**(**__deliveryfirm_id__**, name) \\ **DELIVERY_ASSIGNMENT**(**__deliveryfirm_id*__**(DELIVERY_FIRM), **__user_id*__**(DELIVERY_MAN)) \\ **RESTAURANT**(**__restaurant__id**, name, website_url, opening_time, closing_time, email, phone_number) \\ **RESTAURANT_OWNERS**(**__user_id*__**(RESTAURANT_OWNER), **__restaurant_id*__**(RESTAURANT)) \\ **COSTS**(**__cost_id__**, **__restaurant_id*__**(RESTAURANT), date, amount, type) \\ **EARNINGS**(**__earning_id__**, **__restaurant_id*__**(RESTAURANT), date, amount, source) \\ **MENU**(**__menu_id__**, **__restaurant_id*__**(RESTAURANT), created_at, updated_at, name) \\ **CATEGORY**(**__category_id__**, name, description) \\ **RESTAURANT_CATEGORY**(**__category_id*__**(CATEGORY), **__restaurant_id*__**(RESTAURANT)) \\ **ITEM_CATEGORY**(**__category_id*__**(CATEGORY), **__item_id*__**(ITEM)) \\ **ADDRESS**(**__address_id__**, city, street, postal_code) \\ **USER_ADDRESSES**(**__address_id*__**(ADDRESS), **__user_id*__**(USER))