Skip to content

Object Data Model

Joanna Yao edited this page Mar 20, 2023 · 28 revisions

Objects: User, Order, Merchant, Product

Relationships:

  • User directly refers to Order, indirectly refers to Product via product_name
  • Order indirectly refers to Product via product_name, and to User via username
  • Merchant directly refers to Product

User:

{
   "username" : String,        // UNIQUE (PK), URL-SAFE
   "password" : String,        // Salted, Hashed Password.
   "full_name" : String,
   "history" : [Order],        // list of all past orders         
}

Order:

{
   "username" : String,
   "items" : [{
       "title": String,
       "quantity": Integer,
   }],
   "transaction_id": String
   "totals" : Number,
   "address" : String    // Delivery address
   "status": String      // unpaid -> paid -> sent -> delivered
}

Merchant:

{
   "name" : String,           // UNIQUE (PK), URL-SAFE
   "location" : ?String,      // optional, default to Lawrenceville
   "menu" : [{
       "product": Product,
       "inventory": Integer,
   }]
}

Product:

{
   "title" : String,       // UNIQUE (PK), URL-SAFE
   "display_name": String,
   "price" : Number,    
   "image" : String,       // path to image
}

The following schema is only used for API data format; there is no corresponding table or data in DB

Drone:

{
   "id" : String,
   "drone_name" : String,
   "status" : String   // default to available, can also be in_route
}
Clone this wiki locally