We need to plan out what our Data Structures will look like.

We’re going to use ChatGPT to help with this. But before we start designing our prompts, we need to do a little pre-planning.

First, let’s think about the frontend. The frontend is going to be an iOS App. The user will be able to browse listings and book reservations. Let’s abstract this into a prototype data structure:

Fields Needed: Hotel Name, Address, City, Local Region (i.e. State, Province, etc), Total Hotel Rooms, Room Number, Beds, Bathrooms, Category, Max Occupants, Accessability Status, Smoking Allowed, Pets Allowed, Breakfast Included, Check in time, check out time, dates available.

Right away, we can "see" different entities that exist withing our needed fields. They are Property, Room, Amenities, Rules, and Availability.

In cases like this, ChatGPT is a massive time saver. Let’s take this information and mold it into a prompt.


The fields needed are: Hotel Name, Address, City, Local Region (i.e. State, Province, etc), Total Hotel Rooms, Room Number, Beds, Bathrooms, Category, Max Occupants, Accessability Status, Smoking Allowed, Pets Allowed, Breakfast Included, Check in time, check out time, dates available.

Additionally, I've identified five possible entities that we might want to create.  They are Property, Room, Amenities, Rules, and Availability.  The Property, Room and Amenities entities should support photos.

Based on this information, suggest JSON data structures that we can consider.

Output
Certainly! Given the entities you’ve identified and the fields that are necessary, we can design a JSON structure for your MongoDB documents that compartmentalizes the information into logical sections. MongoDB stores data in documents, which are JSON-like field and value pairs. BSON, the format used by MongoDB, supports embedded documents and arrays, allowing you to effectively model the data in a hierarchical manner that aligns with your entities.

Here’s an example of how you might structure your JSON documents for the hotel booking app:

{
  "Property": {
    "HotelName": "Example Hotel",
    "Address": "123 Example Street",
    "City": "Example City",
    "LocalRegion": "Example State",
    "TotalHotelRooms": 100,
    "Photos": ["url_to_photo1.jpg", "url_to_photo2.jpg"],
    "Amenities": {
      "Photos": ["url_to_amenity_photo1.jpg", "url_to_amenity_photo2.jpg"],
      "AccessibilityStatus": "Wheelchair accessible",
      "SmokingAllowed": false,
      "PetsAllowed": true,
      "BreakfastIncluded": true
    },
    "Rules": {
      "CheckInTime": "15:00",
      "CheckOutTime": "11:00"
    }
  },
  "Rooms": [
    {
      "RoomNumber": "101",
      "Photos": ["url_to_room_photo1.jpg", "url_to_room_photo2.jpg"],
      "Beds": 2,
      "Bathrooms": 1,
      "Category": "Deluxe",
      "MaxOccupants": 4,
      "Amenities": {
        "WiFi": true,
        "AirConditioning": true,
        "RoomService": true
      }
    },
    {
      "RoomNumber": "102",
      // ... other room details
    }
    // ... additional rooms
  ],
  "Availability": [
    {
      "RoomNumber": "101",
      "DatesAvailable": [
        "2023-12-01",
        "2023-12-02",
        // ... additional dates
      ]
    },
    {
      "RoomNumber": "102",
      // ... other room availability details
    }
    // ... additional availability per room
  ]
}

This structure allows for scalability in terms of adding more rooms or updating the availability as needed without impacting other parts of the document. The use of arrays for Rooms and Availability also makes it easy to manage and query against individual room details and their corresponding available dates.

Here are some considerations and suggestions for your design:

  • Property Entity: Includes static information about the hotel itself. Fields like HotelName, Address, City, and LocalRegion would fit here.
  • Photos: Photos for Property, Amenities, and Rooms are included within their respective sections.
  • Room Entity: Embedded as an array within the document to support multiple rooms per hotel. Each room has its own amenities and photos.
  • Amenities Entity: Could be part of the Property if they are hotel-wide, or part of each Room if they vary per room. The example includes both cases for illustration.
  • Rules Entity: Includes information about check-in and check-out times, which typically apply to the entire property.
  • Availability Entity: This is also an array indicating the availability of each room. You can opt to store only dates when the room is available or include detailed booking data depending on your application needs.

By creating this hierarchical document structure, you will be able to efficiently perform operations that are common in hotel booking scenarios, like checking the availability of rooms, updating room information, and retrieving details about the property and amenities for display on the front end.

End ChatGPT Output

I mostly agree with this proposed structure.

{
  "Property": {
    "HotelName": "Example Hotel",
    "Address": "123 Example Street",
    "City": "Example City",
    "LocalRegion": "Example State",
    "TotalHotelRooms": 100,
    "Photos": ["url_to_photo1.jpg", "url_to_photo2.jpg"],
    "PropertyAmenities": {
      "Photos": ["url_to_amenity_photo1.jpg", "url_to_amenity_photo2.jpg"],
    },
    "Rules": {
      "CheckInTime": "15:00",
      "CheckOutTime": "11:00"
      "SmokingAllowed": false,
      "PetsAllowed": true,
      "BreakfastIncluded": true
}
  },
  "Rooms": [
    {
      "RoomNumber": "101",
      "Photos": ["url_to_room_photo1.jpg", "url_to_room_photo2.jpg"],
      "Beds": 2,
      "Bathrooms": 1,
      "Category": "Deluxe",
      "MaxOccupants": 4,
      "Amenities": {
        "WiFi": true,
        "AirConditioning": true,
        "RoomService": true,
        "AccessibilityStatus": "Wheelchair accessible",
      }
    },
    {
      "RoomNumber": "102",
      // ... other room details
    }
    // ... additional rooms
  ],
  "Availability": [
    {
      "RoomNumber": "101",
      "DatesAvailable": [
        "2023-12-01",
        "2023-12-02",
        // ... additional dates
      ]
    },
    {
      "RoomNumber": "102",
      // ... other room availability details
    }
    // ... additional availability per room
  ]
}

But we’re missing a few things.

Prompt:

This is a 'Rooms' subdocument.  "Rooms": [
    {
      "RoomNumber": "101",
      "Photos": ["url_to_room_photo1.jpg", "url_to_room_photo2.jpg"],
      "Beds": 2,
      "Bathrooms": 1,
      "Category": "Deluxe",
      "MaxOccupants": 4,
      "Amenities": {
        "WiFi": true,
        "AirConditioning": true,
        "RoomService": true,
        "AccessibilityStatus": "Wheelchair accessible",
      }
    }

Our possible list of amenities is a bit thin.  Please expand upon this

and the Output:

Certainly! Expanding on the list of amenities can make the accommodation more appealing and provide a clear idea to potential guests of what they can expect. Below is an extended list of amenities you might consider for the "Rooms" subdocument:

"Rooms": [
  {
    "RoomNumber": "101",
    "Photos": ["url_to_room_photo1.jpg", "url_to_room_photo2.jpg"],
    "Beds": 2,
    "Bathrooms": 1,
    "Category": "Deluxe",
    "MaxOccupants": 4,
    "Amenities": {
      "WiFi": true,
      "AirConditioning": true,
      "RoomService": true,
      "AccessibilityStatus": "Wheelchair accessible",
      "Television": true,
      "CableChannels": true,
      "CoffeeMaker": true,
      "Desk": true,
      "IroningFacilities": true,
      "Minibar": true,
      "HairDryer": true,
      "Safe": true,
      "Telephone": true,
      "Bathrobe": true,
      "Slippers": true,
      "AlarmClock": true,
      "ChargingPorts": true,
      "BathtubOrShower": "Bathtub",
      "Heating": true,
      "Soundproofing": true,
      "DailyHousekeeping": true,
      "Towels": true,
      "Linens": true,
      "Toiletries": true,
      "SmokeDetector": true,
      "FireExtinguisher": true,
      "Balcony": true,
      "SeaView": false,
      "PoolAccess": false,
      "ComplimentaryBreakfast": true,
      "FitnessCenterAccess": true,
      "SpaAccess": false,
      "BusinessCenterAccess": true,
      "ConciergeService": true,
      "ChildcareServices": false,
      "PetFriendly": false,
      "Kitchenette": false,
      "LaundryService": true,
      "EcoFriendlyOptions": true,
      "LocalArtworkDisplays": true,
      "SmartHomeDevices": false
    }
  }
  // ... additional rooms could follow in the array
]

In this updated amenities list, I’ve included a variety of features that cater to different needs and preferences. Depending on the type of accommodation and your target audience, you might offer only some of these amenities or even more specialized ones.

Remember to ensure that the information is accurately reflected in your actual service offerings, as guests will expect these amenities to be available during their stay.

The Availability Subdocument doesn’t really work.

  "Availability": [
    {
      "RoomNumber": "101",
      "DatesAvailable": [
        "2023-12-01",
        "2023-12-02",
        // ... additional dates
      ]
    }
]

So here’s my next prompt:

```
  "Availability": [
    {
      "RoomNumber": "101",
      "DatesAvailable": [
        "2023-12-01",
        "2023-12-02",
        // ... additional dates
      ]
    }
]

This subdocument doesn’t really work, because we need a starting date as to when the room is available and an end date when the room is not available. In the future, we’re going to query for this.


And the Output

"Availability": [
{
"RoomNumber": "101",
"AvailablePeriods": [
{
"StartDate": "2023-12-01",
"EndDate": "2023-12-15"
},
// … additional periods
]
}
// … additional rooms with their availability
]


So our current data structure is going to look like this:

{
"Property": {
"HotelName": "Example Hotel",
"Address": "123 Example Street",
"City": "Example City",
"LocalRegion": "Example State",
"TotalHotelRooms": 100,
"Photos": [
"url_to_photo1.jpg",
"url_to_photo2.jpg"
],
"Amenities": {
"Photos": [
"url_to_amenity_photo1.jpg",
"url_to_amenity_photo2.jpg"
]
},
"Rules": {
"CheckInTime": "15:00",
"CheckOutTime": "11:00",
"SmokingAllowed": false,
"PetsAllowed": true,
"BreakfastIncluded": true
}
},
"RoomType": [
{
"Photos": [
"url_to_room_photo1.jpg",
"url_to_room_photo2.jpg"
],
"Beds": 2,
"Bathrooms": 1,
"Category": "Deluxe",
"MaxOccupants": 4,
"Amenities": {
"WiFi": true,
"AirConditioning": true,
"RoomService": true,
"AccessibilityStatus": "Wheelchair accessible",
"Television": true,
"CableChannels": true,
"CoffeeMaker": true,
"Desk": true,
"IroningFacilities": true,
"Minibar": true,
"HairDryer": true,
"Safe": true,
"Telephone": true,
"Bathrobe": true,
"Slippers": true,
"AlarmClock": true,
"ChargingPorts": true,
"BathtubOrShower": "Bathtub",
"Bathtub":true,
"Heating": true,
"Soundproofing": true,
"DailyHousekeeping": true,
"Towels": true,
"Linens": true,
"Toiletries": true,
"SmokeDetector": true,
"FireExtinguisher": true,
"Balcony": true,
"SeaView": false,
"PoolAccess": false,
"ComplimentaryBreakfast": true,
"FitnessCenterAccess": true,
"SpaAccess": false,
"BusinessCenterAccess": true,
"ConciergeService": true,
"ChildcareServices": false,
"PetFriendly": false,
"Kitchenette": false,
"LaundryService": true,
"EcoFriendlyOptions": true,
"LocalArtworkDisplays": true,
"SmartHomeDevices": false
},
"Availability": [
{
"RoomNumber": "101",
"AvailablePeriods": [
{
"StartDate": "2023-12-01",
"EndDate": "2023-12-15"
}
]
}
]
}
]
}


I made a few adjustments.  First, most hotels probably aren't going to want to input individual rooms.  Instead, they will have Room Types and can make those available.  Additionally, I moved Availability under the Room Type.

Finally, I feel like we should distinguish between property amenities and room amenities.  
"PropertyAmenities": {
  "Photos": ["url_to_amenity_photo1.jpg", "url_to_amenity_photo2.jpg"],
},

Flesh out properties amenities to include boolean variables for any and all amenities that might be on site.


Output

Certainly, a "PropertyAmenities" object can include a wide range of amenities that a property might offer. Below, I’ve expanded the "PropertyAmenities" object to include a variety of boolean variables representing common amenities. These can be set to true if the amenity is available or false if it is not.

"PropertyAmenities": {
  "Photos": [
    "url_to_amenity_photo1.jpg",
    "url_to_amenity_photo2.jpg"
  ],
  "WiFi": true,
  "SwimmingPool": true,
  "Parking": true,
  "Gym": true,
  "SpaServices": false,
  "Restaurant": true,
  "Bar": true,
  "RoomService": true,
  "LaundryService": true,
  "BusinessCenter": true,
  "ConferenceRooms": true,
  "BanquetFacilities": false,
  "ChildcareServices": false,
  "ConciergeService": true,
  "CurrencyExchangeService": false,
  "GiftShop": true,
  "AccessibilityFeatures": true,
  "AirportShuttle": true,
  "CarRentalDesk": false,
  "Casino": false,
  "GolfCourse": false,
  "TennisCourts": false,
  "PrivateBeachAccess": false,
  "SkiInSkiOutAccess": false,
  "BikeRental": true,
  "ElectricVehicleChargingStation": true,
  "PetFriendly": true,
  "NonSmoking": true,
  "24HourFrontDesk": true,
  "Sauna": false,
  "TurkishBath": false,
  "Solarium": false,
  "HotTub": false,
  "Library": true,
  "GameRoom": true,
  "ChildrensPlayArea": false,
  "OutdoorGrill": true,
  "PicnicArea": true,
  "FirePit": true,
  "Garden": true,
  "RooftopTerrace": true,
  "LiveEntertainment": false,
  "CookingClasses": false,
  "YogaClasses": false,
  "MeditationAreas": false,
  "WaterSportsFacilities": false,
  "DivingCenter": false,
  "Snorkeling": false,
  "SurfingLessons": false
}

Remember, the specific amenities you list will depend on the property in question. You can add or remove amenities from this list according to what the actual hotel offers. For the sake of example, I’ve mixed in a variety of common and less-common amenities and randomly set some to true and some to false.



[Final Data Structure For Listings](/hotel-booking-app/data-structure/listings-data-structure)
Scroll to Top