0% found this document useful (0 votes)
17 views3 pages

DB TBL

The document outlines the structure of a database for managing users (farmers, consumers, retailers) and their interactions. It includes tables for users, farmers, retailers, products, orders, order items, payments, waste management, and reviews, detailing the purpose and columns for each table. Each table is designed to store specific information relevant to its function within the system.

Uploaded by

vijaypawar04891
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

DB TBL

The document outlines the structure of a database for managing users (farmers, consumers, retailers) and their interactions. It includes tables for users, farmers, retailers, products, orders, order items, payments, waste management, and reviews, detailing the purpose and columns for each table. Each table is designed to store specific information relevant to its function within the system.

Uploaded by

vijaypawar04891
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

02.

28 7:03 PM
Database Tables

• . Users Table (Farmers, Consumers, Retailers)


purpose: Stores user information.
columns:
1. user_id (INT, PRIMARY KEY, AUTO_INCREMENT)
2. user_type (ENUM: 'farmer', 'consumer', 'retailer')
3. full_name (VARCHAR)
4. email (VARCHAR, UNIQUE)
5. phone_number (VARCHAR, UNIQUE)
6. password_hash (VARCHAR)
7. address (TEXT)
8. city (VARCHAR)
9. account_status (ENUM: 'active', 'inactive', 'blocked', DEFAULT 'active')

• Farmers Table (Extends Users)


purpose: Stores farmer-specific details.
columns:
1. farmer_id (INT, PRIMARY KEY, FOREIGN KEY referencing users.user_id)
2. farm_name (VARCHAR, NULLABLE)
3. farm_location (TEXT, NULLABLE)
4. land_size (DECIMAL, NULLABLE)
5. farm_registration_number (VARCHAR, NULLABLE)
6. bank_account_number (VARCHAR, NULLABLE)
7. ifsc_code (VARCHAR, NULLABLE)

• Retailers Table (Extends Users)


purpose: Stores retailer-specific details.
columns:
1. retailer_id (INT, PRIMARY KEY, FOREIGN KEY referencing users.user_id)
2. store_name (VARCHAR)
3. store_location (TEXT)
4. gst_number (VARCHAR, NULLABLE)

•. Products Table
purpose: Stores information about the products listed by farmers.
columns:
1. product_id (INT, PRIMARY KEY, AUTO_INCREMENT)
2. farmer_id (INT, FOREIGN KEY referencing farmers.farmer_id)
3. product_name (VARCHAR)
4. description (TEXT, NULLABLE)
5. category (VARCHAR)
6. unit (VARCHAR, e.g., kg, piece, bunch)
7. price_per_unit (DECIMAL)
8. available_quantity (DECIMAL)
9. image_url (VARCHAR, NULLABLE)
10 expiry_date (DATE, NULLABLE)
11. organic (BOOLEAN, DEFAULT FALSE)
•. Orders Table
purpose: Stores order details.
columns:
1. order_id (INT, PRIMARY KEY, AUTO_INCREMENT)
2. consumer_id (INT, FOREIGN KEY referencing users.user_id)
3. farmer_id (INT, FOREIGN KEY referencing farmers.farmer_id)
4. retailer_id (INT, NULLABLE, FOREIGN KEY referencing retailers.retailer_id)
5. order_date (TIMESTAMP, DEFAULT CURRENT_TIMESTAMP)
6. delivery_date (DATE, NULLABLE)
7. delivery_address (TEXT)
8. order_status (ENUM: 'pending', 'confirmed', 'shipped', 'delivered',
'cancelled', 'refunded')
9. total_amount (DECIMAL)

•. OrderItems Table
purpose: Stores individual items within an order.
columns:
1. order_item_id (INT, PRIMARY KEY, AUTO_INCREMENT)
2. order_id (INT, FOREIGN KEY referencing orders.order_id)
3. product_id (INT, FOREIGN KEY referencing products.product_id)
4. quantity (DECIMAL)
5. unit_price (DECIMAL)
6. subtotal (DECIMAL)

• . Payments Table
purpose: Stores payment transaction details.
columns:
1. payment_id (INT, PRIMARY KEY, AUTO_INCREMENT)
2. order_id (INT, FOREIGN KEY referencing orders.order_id)
3. payment_date (TIMESTAMP, DEFAULT CURRENT_TIMESTAMP)
4. payment_method (VARCHAR)
5. transaction_id (VARCHAR)
6. payment_status (ENUM: 'pending', 'success', 'failed')
7. payment_amount (DECIMAL)

•. WasteManagement Table
purpose: Stores information related to waste management.
columns:
1. waste_id (INT, PRIMARY KEY, AUTO_INCREMENT)
2. farmer_id (INT, FOREIGN KEY referencing farmers.farmer_id)
3. waste_type (VARCHAR)
4. quantity (DECIMAL)
5. unit (VARCHAR)
6. description (TEXT, NULLABLE)
7. pickup_date (DATE, NULLABLE)
8. pickup_status (ENUM: 'requested', 'scheduled', 'collected', 'disposed')
•. . Reviews Table
purpose: Stores product and farmer reviews.
columns:
1. review_id (INT, PRIMARY KEY, AUTO_INCREMENT)
2. product_id (INT, FOREIGN KEY referencing products.product_id, NULLABLE)
3. farmer_id (INT, FOREIGN KEY referencing farmers.farmer_id, NULLABLE)
4. consumer_id (INT, FOREIGN KEY referencing users.user_id)
5. rating (INT)
6. comment (TEXT, NULLABLE)
7. review_date (TIMESTAMP, DEFAULT CURRENT_TIMESTAMP)

You might also like