diff --git a/README.md b/README.md index 06493e9..6894488 100644 --- a/README.md +++ b/README.md @@ -75,74 +75,119 @@ By completing this assignment, you will be able to: - Implement **CRUD** (Create, Read, Update, Delete) operations via Java. - Build a modular and object-oriented backend application. - + ## 🏗️ Database Entities & Schema -Your database must be created via a `database.sql` script. This file must include all `CREATE TABLE` statements, keys, constraints, and initial mock data. +Your database must be created using a `database.sql` script. -Here are the required entities: +The script must include: + +* Table creation statements +* Keys and relationships +* Appropriate constraints +* Initial mock data + +You are responsible for selecting appropriate: + +* Data types +* Primary Keys +* Foreign Keys +* Constraints (e.g., `NOT NULL`, `UNIQUE`, `CHECK`, `DEFAULT`) + +Your design decisions will be evaluated as part of the assignment. + +--- ### 1. User (Customer) Represents a customer using the system. -- **id:** `SERIAL PRIMARY KEY` - -- **username:** `VARCHAR` (Required, UNIQUE) - -- **password:** `TEXT` (Required, stored as a hashed value) - -- **email:** `VARCHAR` (Optional) - -- _Relationship:_ A User can have many Orders (1-to-N). - +Required Information: + +* Unique identifier +* Username +* Password +* Email (optional) + +Requirements: + +* Usernames must be unique. +* Passwords must not be stored in plain text. +* A user can place multiple orders. + +--- ### 2. MenuItem -Represents the food/drink items available in the restaurant. +Represents a food or drink available in the restaurant. -- **id:** `SERIAL PRIMARY KEY` - -- **name:** `VARCHAR` (Required) - -- **description:** `TEXT` (Optional) - -- **price:** `NUMERIC` or `DECIMAL` (Required, must be strictly positive) - -- **category:** `VARCHAR` (Optional) - -- _Requirement:_ You must pre-populate this table with at least 3 items using `INSERT` statements in your SQL file. - +Required Information: + +* Unique identifier +* Name +* Description (optional) +* Price +* Category (optional) + +Requirements: + +* Every item must have a positive price. +* The database must contain at least 3 menu items inserted through the SQL script. + +--- ### 3. Order Represents a specific order placed by a customer. -- **id:** `SERIAL PRIMARY KEY` - -- **userId:** `FOREIGN KEY` (References `User.id`) - -- **createdAt:** `TIMESTAMP` (Default to current time) - -- **totalPrice:** `NUMERIC` or `DECIMAL` - -- _Relationship:_ An Order belongs to one User. An Order contains many OrderDetails (1-to-N). - +Required Information: + +* Unique identifier +* Reference to the customer who placed the order +* Creation date and time +* Total price + +Requirements: + +* An order belongs to exactly one user. +* A user can have multiple orders. +* An order can contain multiple items. + +--- ### 4. OrderDetail -Acts as a bridge table storing the specific items and quantities inside a single order. +Represents an item inside an order. + +Required Information: + +* Unique identifier +* Reference to an order +* Reference to a menu item +* Quantity +* Item price at the time of purchase + +Requirements: + +* Quantity must always be greater than zero. +* The stored price should represent the item's price when the order was placed. +* An order can contain multiple order details. + +--- + +### Design Notes + +Before implementing the schema, identify: + +* The primary key of each entity. +* The foreign key relationships. +* Any uniqueness constraints. +* Any required fields. +* Any validation rules that should be enforced by the database. + +Your schema should be normalized and designed to avoid unnecessary data duplication. -- **id:** `SERIAL PRIMARY KEY` - -- **orderId:** `FOREIGN KEY` (References `Order.id`) - -- **menuItemId:** `FOREIGN KEY` (References `MenuItem.id`) - -- **quantity:** `INTEGER` (Must be > 0) - -- **price:** `NUMERIC` (Snapshot of the item's price at the time of purchase) ## 💻 Required Features & App Flow