| 1 | == ER Diagram == |
| 2 | |
| 3 | === Entities === |
| 4 | |
| 5 | * **Entity: User** |
| 6 | * **Description**: Contains main information about all users in the system. |
| 7 | * **Primary Key**: `id`. |
| 8 | * **Attributes**: |
| 9 | * **email**: User's email address. |
| 10 | * **street**: Street address of the user. |
| 11 | * **city**: City of residence. |
| 12 | * **phone_number**: Contact phone number. |
| 13 | * **password**: Encrypted user password. |
| 14 | |
| 15 | * **Entity: Employee** |
| 16 | * **Description**: Represents employees of the system. |
| 17 | * **Primary Key**: `id`. |
| 18 | * **Attributes**: |
| 19 | * **user_id**: Foreign key referencing `User`. |
| 20 | * **net_salary**: The net salary of the employee. |
| 21 | * **gross_salary**: The gross salary of the employee. |
| 22 | |
| 23 | * **Entity: Customer** |
| 24 | * **Description**: Represents customers in the system. |
| 25 | * **Primary Key**: `id`. |
| 26 | * **Attributes**: |
| 27 | * **user_id**: Foreign key referencing `User`. |
| 28 | |
| 29 | * **Entity: Manager** |
| 30 | * **Description**: A disjoint specialization of the `Employee` entity for managers. |
| 31 | * **Primary Key**: `employee_id`. |
| 32 | |
| 33 | * **Entity: FrontStaff** |
| 34 | * **Description**: A disjoint specialization of the `Employee` entity for front-facing staff members. |
| 35 | * **Primary Key**: `employee_id`. |
| 36 | * **Attributes**: |
| 37 | * **tip_percent**: Percentage of tips allocated to the staff. |
| 38 | * **staff_role_id**: Foreign key referencing `StaffRole`. |
| 39 | |
| 40 | * **Entity: BackStaff** |
| 41 | * **Description**: A disjoint specialization of the `Employee` entity for back-office staff members. |
| 42 | * **Primary Key**: `employee_id`. |
| 43 | * **Attributes**: |
| 44 | * **staff_role_id**: Foreign key referencing `StaffRole`. |
| 45 | |
| 46 | * **Entity: StaffRole** |
| 47 | * **Description**: Defines roles for staff members. |
| 48 | * **Primary Key**: `id`. |
| 49 | * **Attributes**: |
| 50 | * **name**: Name of the staff role. |
| 51 | |
| 52 | |
| 53 | * **Entity: Shift** |
| 54 | * **Description**: Represents a work shift in the system. |
| 55 | * **Primary Key**: `id`. |
| 56 | * **Attributes**: |
| 57 | * **date**: Date of the shift. |
| 58 | * **start**: Start time of the shift. |
| 59 | * **end**: End time of the shift. |
| 60 | * **employee_id**: Foreign key referencing `Manager`. |
| 61 | |
| 62 | * **Entity: Assignment** |
| 63 | * **Description**: Represents shift assignment for each employee. |
| 64 | * **Primary Key**: `id`. |
| 65 | * **Attributes**: |
| 66 | * **clock_in_time**: Clock in time of the employee. |
| 67 | * **clock_out_time**: Clock out time of the employee. |
| 68 | * **manager_id**: Foreign key referencing `Manager`. |
| 69 | * **employee_id**: Foreign key referencing `Employee`. |
| 70 | * **shift_id**: Foreign key referencing `Shift`. |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | * **Entity: Reservation** |
| 76 | * **Description**: Represents reservations made by users. |
| 77 | * **Primary Key**: `id`. |
| 78 | * **Attributes**: |
| 79 | * **stay_length**: Duration of the stay. |
| 80 | * **datetime**: Date and time of the reservation. |
| 81 | * **creation_timestamp**: Timestamp when the reservation was created. |
| 82 | * **number_of_people**: Number of people in the reservation. |
| 83 | * **customer_id**: Foreign key referencing `Customer`. |
| 84 | |
| 85 | |
| 86 | * **Entity: Category** |
| 87 | * **Description**: Represents product categories. |
| 88 | * **Primary Key**: `id`. |
| 89 | * **Attributes**: |
| 90 | * **name**: Name of the category. |
| 91 | * **is_available**: Availability status of the category. |
| 92 | |
| 93 | * **Entity: Product** |
| 94 | * **Description**: Represents items that can be purchased in the system. |
| 95 | * **Primary Key**: `id`. |
| 96 | * **Attributes**: |
| 97 | * **name**: Name of the product. |
| 98 | * **price**: Price of the product. |
| 99 | * **tax_class**: Tax classification for the product. |
| 100 | * **description**: Description of the product. |
| 101 | * **category_id**: Foreign key referencing `Category`. |
| 102 | * **manage_inventory**: Boolean indicating if inventory is managed. |
| 103 | |
| 104 | * **Entity: Inventory** |
| 105 | * **Description**: Tracks product quantities and restocking levels. |
| 106 | * **Primary Key**: `product_id`. |
| 107 | * **Attributes**: |
| 108 | * **quantity**: Current stock quantity. |
| 109 | * **restock_level**: Minimum stock level before restocking is required. |
| 110 | |
| 111 | * **Entity: OrderItem** |
| 112 | * **Description**: Represents items in a customer's order. |
| 113 | * **Primary Key**: `id`. |
| 114 | * **Attributes**: |
| 115 | * **quantity**: Quantity of the product ordered. |
| 116 | * **price**: Price of the product in the order. |
| 117 | * **is_processed**: Processing status of the item. |
| 118 | * **timestamp**: Time when the item was added. |
| 119 | * **product_id**: Foreign key referencing `Product`. |
| 120 | * **order_id**: Foreign key referencing `Order`. |
| 121 | |
| 122 | * **Entity: Order** |
| 123 | * **Description**: Represents a customer's order in the system. |
| 124 | * **Primary Key**: `id`. |
| 125 | * **Attributes**: |
| 126 | * **timestamp**: Time when the order was placed. |
| 127 | * **status**: Status of the order. |
| 128 | * **employee_id**: Foreign key referencing `Employee`. |
| 129 | |
| 130 | * **Entity: TabOrder** |
| 131 | * **Description**: Represents orders made at a specific table. |
| 132 | * **Primary Key**: `order_id`. |
| 133 | * **Attributes**: |
| 134 | * **table_number**: Foreign key referencing `Table`. |
| 135 | |
| 136 | * **Entity: OnlineOrder** |
| 137 | * **Description**: Represents orders made online by customers. |
| 138 | * **Primary Key**: `order_id`. |
| 139 | * **Attributes**: |
| 140 | * **customer_id**: Foreign key referencing `Customer`. |
| 141 | |
| 142 | * **Entity: Table** |
| 143 | * **Description**: Represents dining tables in the system. |
| 144 | * **Primary Key**: `table_number`. |
| 145 | * **Attributes**: |
| 146 | * **seat_capacity**: Seating capacity of the table. |
| 147 | |
| 148 | * **Entity: Payment** |
| 149 | * **Description**: Represents payments for orders. |
| 150 | * **Primary Key**: `id`. |
| 151 | * **Attributes**: |
| 152 | * **tip_amount**: Amount of tip included. |
| 153 | * **timestamp**: Time of payment. |
| 154 | * **payment_type**: Type of payment (e.g., cash, card). |
| 155 | * **amount**: Total payment amount. |
| 156 | * **order_id**: Foreign key referencing `Order`. |
| 157 | |
| 158 | |
| 159 | === Relationships === |
| 160 | |
| 161 | * **belongs_to** 1:N Relation between `Category` and `Product`. |
| 162 | * Description: Indicates which category a product belongs to. |
| 163 | |
| 164 | * **is_in**: 1:1 Relation between `Product` and `Inventory`. |
| 165 | * Description: Indicates the product's record in inventory. |
| 166 | |
| 167 | * **is**: 1:N Relation between `Product` and `OrderItem`. |
| 168 | * Description: Indicates which products are order items. |
| 169 | |
| 170 | * **has**: 1:M Relation between `Order` and `OrderItem`. |
| 171 | * Description: Indicates which order items belong to a given order. |
| 172 | |
| 173 | * **places_order**: 1:P Relation between `Customer` and `OnlineOrder`. |
| 174 | * Description: Indicates which online order a customer placed. |
| 175 | |
| 176 | * **is_placed_on**: 1:M Relation between `Table` and `TabOrder`. |
| 177 | * Description: Indicates which table a tab order is placed on. |
| 178 | |
| 179 | * **has_payment**: 1:1 Relation between `Order` and `Payment`. |
| 180 | * Description: Indicates the payment for the given order. |
| 181 | |
| 182 | * **creates**: 1:M Relation between `Manager` and `Shift`. |
| 183 | * Description: Indicates the manager's created shifts. |
| 184 | |
| 185 | * **assigns**: 1:N Relation between `Manager`, and `Assignment`. |
| 186 | * Description: Indicates a manager making an assignment. |
| 187 | |
| 188 | * **assigned_to**: 1:N Relation between `Employee`, and `Assignment`. |
| 189 | * Description: Indicates which employee has the assignment. |
| 190 | |
| 191 | * **is_assigned**: 1:N Relation between `Shift`, and `Assignment`. |
| 192 | * Description: Indicates which shift is assigned. |
| 193 | |
| 194 | * **makes**: 1:P Relation between `Customer` and `Reservation`. |
| 195 | * Description: Indicates which customer makes the reservation. |
| 196 | |
| 197 | * **has_role**: 1:N Relation between `StaffRole` and `BackStaff`/`FrontStaff`. |
| 198 | * Description: Indicates the role of back-staff/front-staff employees. |