I could use some tips on my DB design

I have extensive experience working with SQL DBs, but this is my first time trying my hand at designing something in mongoDB. I am developing a reservation engine for a multi-hotel site. I came up with this model. I have done a lot of reading and I am not sure if I am going in the right direction or if I should take a ifferent aproach.

    {
  "id": "#####",
  "name": "hotel name"
  "state": "some state",
  "city": "some city"
  "category": "category",
  "address": "address",
  "phone": "phone",
  "email": "email",
  "users":[
    {
      "fName": "name",
      "lName": "name",
      "email": "email@mail.com",
      "password": "hashedsecretthing",
      "accessLevel": "accessLevel"
    }
  ],
  "rooms":[
    {
      "name": "roomName",
      "category": "roomCat",
      "max_cap": 0,
      "phy_rooms":[
        {
          "id": "#######",
          "daily":[
            {
              "day":{
                "date": "todaysDate"
                "rate_id": "####"
                "availability": "reservationID/service/maintanace",
              }
            }
          ]
        }
      ],
      "amenities":{
        "amenityName": true
      }
    }
  ]
},
//have 2 documents, ACTIVE and PREVIOS RATES
{
  "hotelID": "#######"
  "id": "#####",
  "rateName": "name",
  "rate": "0.00",
  "tier": "standard/promo/especial/manual",
  "duration":{
    "startDate": "date",
    "endDate": "date"
  },
  "rooms":[
    "roomName",
    ...
  ]
}
//reservations
{
  "hotelID": "#######"
  "id": "########",
  "fName": "name",
  "lName": "name",
  "email": "email",
  "phone": "phone",
  "status": "status",
  "dates":{
    "arrival": "date",
    "departure": "date",
    "createdAt": "date"
  },
  "rooms":[
    {
      "roomID": "######",
      "rateID": "#####",
      "pax": 0
    }
  ],
  "extras":[
    "extraID",
    ...
  ]
}

I have a few questions. I will have multiple hotels managing their rooms, rates, and reservations. Should I enbede the Rates and Reservations documents inside each hotel document, or should I have a large Document for each, only referencing the hotel id?? Is there a better way to handle this?

Hi @christopher_luna, there is a MongoDB University course on Data Modeling that provides guidance on the schema patterns.

2 Likes