NerajnoLearning / Uppfylla

MIT License
0 stars 0 forks source link

Create DB Schema #5

Open Nerajno opened 2 months ago

Nerajno commented 2 months ago

Sure, let's break down each collection in the MongoDB schema for the food delivery app:

  1. Users:

    • This collection stores information about users who interact with the food delivery app.
    • Fields:
      • _id: Unique identifier for each user.
      • username: User's username for identification.
      • email: User's email address for communication.
      • password: User's password (Note: It's generally stored in a hashed format for security).
      • role: User's role in the system (e.g., subscriber, restaurant manager, driver).
      • createdAt: Timestamp indicating when the user account was created.
      • updatedAt: Timestamp indicating when the user account was last updated.
  2. Restaurants:

    • This collection contains information about restaurants available on the platform.
    • Fields:
      • _id: Unique identifier for each restaurant.
      • name: Name of the restaurant.
      • description: Brief description of the restaurant.
      • cuisine: Type of cuisine offered by the restaurant.
      • location: Location of the restaurant (e.g., address).
      • menu: Menu items offered by the restaurant.
      • openingHours: Operating hours of the restaurant.
      • deliveryZones: Areas where the restaurant provides delivery services.
      • createdAt: Timestamp indicating when the restaurant entry was created.
      • updatedAt: Timestamp indicating when the restaurant entry was last updated.
  3. Orders:

    • This collection stores details of orders placed by users.
    • Fields:
      • _id: Unique identifier for each order.
      • userId: Reference to the user who placed the order.
      • restaurantId: Reference to the restaurant from which the order was placed.
      • items: List of items ordered by the user.
      • totalPrice: Total cost of the order.
      • status: Current status of the order (e.g., pending, processing, delivered).
      • createdAt: Timestamp indicating when the order was created.
      • updatedAt: Timestamp indicating when the order was last updated.
  4. Drivers:

    • This collection contains information about delivery drivers working for the food delivery service.
    • Fields:
      • _id: Unique identifier for each driver.
      • Name: Name of the driver.
      • email: Email address of the driver.
      • vehicle type: Type of vehicle used by the driver for deliveries (e.g., car, bike).
      • available: Flag indicating the availability status of the driver.
      • createdAt: Timestamp indicating when the driver entry was created.
      • updatedAt: Timestamp indicating when the driver entry was last updated.

These collections and their fields provide a structured way to store and manage data relevant to the food delivery app, facilitating user authentication, restaurant management, order tracking, and driver assignment.

food_delivery_db/ |-- users | |-- _id | |-- username | |-- email | |-- password | |-- role | |-- createdAt | |-- updatedAt |-- restaurants | |-- _id | |-- name | |-- description | |-- cuisine | |-- location | |-- menu | |-- openingHours | |-- deliveryZones | |-- createdAt | |-- updatedAt |-- orders | |-- _id | |-- userId | |-- restaurantId | |-- items | |-- totalPrice | |-- status | |-- createdAt | |-- updatedAt |-- drivers | |-- _id | |-- name | |-- email | |-- vehicleType | |-- available | |-- createdAt | |-- updatedAt