== 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 written in bold and underline. - Foreign keys are marked with asterisk after the attribute name. \\ === Relations - Relational Schema **APP_USER**(**__user_id__**, first_name, last_name, email, password, phone, **__administrator_id*__**(ADMINNISTRATOR)) \\ \\ **ADMINISTRATOR**(**__user_id*__**(APP_USER), authorized_from, authorized_to) \\ \\ **RESTAURANT_OWNER**(**__user_id*__**(APP_USER)) \\ \\ **DELIVERY_MAN**(**__user_id*__**(APP_USER)) \\ \\ **CUSTOMER**(**__user_id*__**(APP_USER)) \\ \\ **ORDERS**(**__order_id__**, **address_id***(ADDRESS), **restaurant_id***(RESTAURANT), **deliveryman_id***(DELIVERY_MAN), **user_id***(CUSTOMER), **__address_id*__**(ADDRESS),order_date, comment, order_status, total_amount) \\ \\ **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__**, **__address_id*__**(ADDRESS), 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) \\ \\ **MENU_ITEM**(**__menu_id*__**(MENU), ***__item_id__**(ITEM)) \\ \\ **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)) \\ \\ **SHOPPING_CART**(**__cart_id__**, **__user_id*__**(USER)) \\ \\ **CART_ITEMS**(**__cart_id*__**(SHOPPING_CART), **__item_id*__**(ITEM), quantity) === DDL Script for deletion and creation of tables [attachment:DDL.sql] \\ === DML Script for insertion of dummy data into tables [attachment:DML.sql] === Relational Schema Diagram [[Image(ticket:8:DATABASE_MODEL.png)]]