Skip to content

This commit adds detailed SQL Database setup instructions to the READ… #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,110 @@ Download mysql for windows: https://dev.mysql.com/downloads/installer/

`pip install mysql-connector-python`


# Grocery Store Database Setup

## Overview

These are instructions for setting up the grocery_store database along with sample data using SQL scripts.

## Setup Instructions

1. Create the `grocery_store` database:

```sql
CREATE DATABASE IF NOT EXISTS grocery_store;
```

2. Switch to the `grocery_store` database:

```sql
USE grocery_store;
```

3. Create the `uom` (unit of measure) table:

```sql
CREATE TABLE IF NOT EXISTS uom (
uom_id INT AUTO_INCREMENT PRIMARY KEY,
uom_name VARCHAR(50)
);
```

4. Insert demo data into the `uom` table:

```sql
INSERT INTO uom (uom_name) VALUES
('Piece'),
('Kilogram'),
('Liter');
```

5. Create the `products` table:

```sql
CREATE TABLE IF NOT EXISTS products (
product_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
uom_id INT,
price_per_unit DECIMAL(10, 2),
FOREIGN KEY (uom_id) REFERENCES uom(uom_id)
);
```

6. Insert demo data into the `products` table:

```sql
INSERT INTO products (name, uom_id, price_per_unit) VALUES
('Apples', 1, 1.99),
('Milk', 3, 2.49),
('Bread', 1, 3.99);
```

7. Create the `orders` table:

```sql
CREATE TABLE IF NOT EXISTS orders (
order_id INT AUTO_INCREMENT PRIMARY KEY,
customer_name VARCHAR(255),
total DECIMAL(10, 2),
datetime DATETIME
);
```

8. Insert demo data into the `orders` table:

```sql
INSERT INTO orders (customer_name, total, datetime) VALUES
('Rudraprasad Mohapatra', 15.97, NOW()),
('Rajarudra Mohapatra', 8.98, NOW());
```

9. Create the `order_details` table with `ON DELETE CASCADE`:

```sql
CREATE TABLE IF NOT EXISTS order_details (
order_detail_id INT AUTO_INCREMENT PRIMARY KEY,
order_id INT,
product_id INT,
quantity INT,
total_price DECIMAL(10, 2),
FOREIGN KEY (order_id) REFERENCES orders(order_id),
FOREIGN KEY (product_id) REFERENCES products(product_id) ON DELETE CASCADE
);
```

10. Insert demo data into the `order_details` table:

```sql
INSERT INTO order_details (order_id, product_id, quantity, total_price) VALUES
(1, 1, 2, 3.98),
(1, 2, 1, 2.49),
(2, 3, 1, 3.99);
```

That's it! You have successfully set up the `grocery_store` database with sample data.

### Exercise

The grocery management system that we built is functional but after we give it to users for use, we got following feedback. The exercise for you to address this feedback and implement these features in the application,
Expand Down
2 changes: 1 addition & 1 deletion ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h2>Grocery Store Management System</h2>
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body text-center">
<img src="https://demo.test.cloint.com/assets/images/spinner.gif" width="40" style="margin: 60px auto;" alt="">
<img src="https://media1.giphy.com/media/v1.Y2lkPTc5MGI3NjExODE0ZmU4dXo5bG41MG9rZnk1ajR1Z21nYW1oaGJjZnVvaGdudDk5NCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/uIJBFZoOaifHf52MER/giphy.gif" width="40" style="margin: 60px auto;" alt="">
</div>
</div>
</div>
Expand Down