This document provides the SQL scripts for initializing the database of a food delivery application and the JSON payloads for key operations. It complements the full-stack application implementation by defining the database structure and API request formats.

1. Database Schema and Initial Data

Restaurants Table

INSERT INTO restaurants (creation_date, updated_on, address, city, description, name, status) VALUES
('2024-05-01', '2024-05-01 11:00:00', '123 FC Road', 'Pune', 'Traditional Maharashtrian meals', 'Shree Misal House', 1),
('2024-05-02', '2024-05-02 14:00:00', '88 JM Road', 'Pune', 'Popular North Indian and tandoor dishes', 'Tandoor Junction', 1),
('2024-05-03', '2024-05-03 17:30:00', '42 Baner Road', 'Pune', 'Modern vegetarian café with fusion food', 'Green Leaf Café', 1);

Food Items Table

INSERT INTO food_items (creation_date, updated_on, is_veg, item_description, item_name, price, restaurant_id) VALUES
('2024-05-01', '2024-05-01 11:10:00', b'1', 'Spicy misal topped with farsan and onions', 'Puneri Misal', 70, 1),
('2024-05-01', '2024-05-01 11:15:00', b'1', 'Sabudana khichdi with peanuts and lemon', 'Sabudana Khichdi', 60, 1),
('2024-05-02', '2024-05-02 14:15:00', b'0', 'Char-grilled chicken with Indian spices', 'Tandoori Chicken', 180, 2),
('2024-05-02', '2024-05-02 14:30:00', b'1', 'Soft naan stuffed with spiced potatoes', 'Aloo Kulcha', 90, 2),
('2024-05-03', '2024-05-03 17:45:00', b'1', 'Millet-based pizza with paneer topping', 'Desi Paneer Pizza', 150, 3),
('2024-05-03', '2024-05-03 18:00:00', b'1', 'Chilled kokum-based beverage', 'Kokum Cooler', 50, 3);

Address Table

INSERT INTO address (creation_date, updated_on, adr_line1, adr_line2, city, country, state, zip_code, phone) VALUES
(CURDATE(), NOW(), 'Flat 201, Sai Heritage', 'FC Road, Shivajinagar', 'Pune', 'India', 'Maharashtra', '411005', '9822345678'),
(CURDATE(), NOW(), 'House No. 34, Kumar Park', 'Lane 2, Kothrud', 'Pune', 'India', 'Maharashtra', '411038', '9922345678'),
(CURDATE(), NOW(), 'Bungalow 7, Nyati County', 'Near Corinthian Club, NIBM Road', 'Pune', 'India', 'Maharashtra', '411060', '9862345678'),
(CURDATE(), NOW(), 'Plot No. 121, Viman Nagar', 'Near Phoenix Marketcity', 'Pune', 'India', 'Maharashtra', '411014', '9822349678'),
(CURDATE(), NOW(), 'Row House 12, Magarpatta City', 'Hadapsar', 'Pune', 'India', 'Maharashtra', '411028', '9822345618'),
(CURDATE(), NOW(), 'Flat 9B, Blue Ridge', 'Phase 1, Hinjewadi', 'Pune', 'India', 'Maharashtra', '411057', '9822315678');

Users Table

-- Admin
INSERT INTO new_users (creation_date, updated_on, dob, email, first_name, image, last_name, password, user_role, address_id, subscription_amount) VALUES
(CURDATE(), NOW(), '1980-01-01', '[email protected]', 'Ravi', NULL, 'Kumar', 'Admin@123', 'ADMIN', 1, 0);

-- Customers
INSERT INTO new_users (creation_date, updated_on, dob, email, first_name, image, last_name, password, user_role, address_id, subscription_amount) VALUES
(CURDATE(), NOW(), '1995-05-15', '[email protected]', 'Neha', NULL, 'Patil', 'Neha@123', 'CUSTOMER', 2, 2000),
(CURDATE(), NOW(), '1990-08-10', '[email protected]', 'Arjun', NULL, 'Sharma', 'Arjun@123', 'CUSTOMER', 3, 1500),
(CURDATE(), NOW(), '1998-12-25', '[email protected]', 'Meera', NULL, 'Khan', 'Meera@123', 'CUSTOMER', 4, 2500);

-- Delivery Persons
INSERT INTO new_users (creation_date, updated_on, dob, email, first_name, image, last_name, password, user_role, address_id, subscription_amount) VALUES
(CURDATE(), NOW(), '1992-07-20', '[email protected]', 'Rohit', NULL, 'Verma', 'Rohit@123', 'DELIVERY_PERSON', 5, 1000),
(CURDATE(), NOW(), '1994-11-05', '[email protected]', 'Anju', NULL, 'Y

adav', 'Anju@123', 'DELIVERY_PERSON', 6, 1300);

2. Sample JSON Payloads

Adding Multiple Food Items to a Specific Restaurant

Endpoint: POST /api/restaurants/{restaurantId}/food-items

Payload:

[
  {
    "itemName": "name-1",
    "itemDescription": "desc-1",
    "price": 200,
    "veg": true
  },
  {
    "itemName": "name-2",
    "itemDescription": "desc-2",
    "price": 300,
    "veg": true
  },
  {
    "itemName": "name-1",
    "itemDescription": "desc-11",
    "price": 210,
    "veg": true
  },
  {
    "itemName": "name-2",
    "itemDescription": "desc-22",
    "price": 350,
    "veg": true
  }
]

Placing an Order

Endpoint: POST /api/orders

Payload:

{
  "customerId": 2,
  "restaurantId": 1,
  "items": [
    {
      "foodItemId": 1,
      "quantity": 2,
      "discount": 10
    },
    {
      "foodItemId": 2,
      "quantity": 3,
      "discount": 5
    }
  ]
}

3. Implementation Notes