Update README.md

This commit is contained in:
2026-06-17 01:18:00 +03:30
parent af735c7a09
commit 97354c2e09
+91 -46
View File
@@ -75,74 +75,119 @@ By completing this assignment, you will be able to:
- Implement **CRUD** (Create, Read, Update, Delete) operations via Java. - Implement **CRUD** (Create, Read, Update, Delete) operations via Java.
- Build a modular and object-oriented backend application. - Build a modular and object-oriented backend application.
## 🏗️ Database Entities & Schema ## 🏗️ 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) ### 1. User (Customer)
Represents a customer using the system. Represents a customer using the system.
- **id:** `SERIAL PRIMARY KEY` Required Information:
- **username:** `VARCHAR` (Required, UNIQUE) * Unique identifier
* Username
- **password:** `TEXT` (Required, stored as a hashed value) * Password
* Email (optional)
- **email:** `VARCHAR` (Optional)
Requirements:
- _Relationship:_ A User can have many Orders (1-to-N).
* Usernames must be unique.
* Passwords must not be stored in plain text.
* A user can place multiple orders.
---
### 2. MenuItem ### 2. MenuItem
Represents the food/drink items available in the restaurant. Represents a food or drink available in the restaurant.
- **id:** `SERIAL PRIMARY KEY` Required Information:
- **name:** `VARCHAR` (Required) * Unique identifier
* Name
- **description:** `TEXT` (Optional) * Description (optional)
* Price
- **price:** `NUMERIC` or `DECIMAL` (Required, must be strictly positive) * Category (optional)
- **category:** `VARCHAR` (Optional) Requirements:
- _Requirement:_ You must pre-populate this table with at least 3 items using `INSERT` statements in your SQL file. * Every item must have a positive price.
* The database must contain at least 3 menu items inserted through the SQL script.
---
### 3. Order ### 3. Order
Represents a specific order placed by a customer. Represents a specific order placed by a customer.
- **id:** `SERIAL PRIMARY KEY` Required Information:
- **userId:** `FOREIGN KEY` (References `User.id`) * Unique identifier
* Reference to the customer who placed the order
- **createdAt:** `TIMESTAMP` (Default to current time) * Creation date and time
* Total price
- **totalPrice:** `NUMERIC` or `DECIMAL`
Requirements:
- _Relationship:_ An Order belongs to one User. An Order contains many OrderDetails (1-to-N).
* An order belongs to exactly one user.
* A user can have multiple orders.
* An order can contain multiple items.
---
### 4. OrderDetail ### 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 ## 💻 Required Features & App Flow