Data Modeling and Search Practices for Accommodation Information Systems

    This article walks through the data modeling and retrieval practices behind accommodation information systems. It explains how to split a single listing into four entity types, model amenities as tags, store coordinates for distance calculations, structure check-in and pet policies with validation, define an order confirmation state machine, and combine indexes and filters for search. It also covers the data quality and observability metrics to monitor after launch.

    1. Why a Single Listing Is Already Complex

    A listing that looks simple usually carries more than a dozen categories of information: name, address, amenities, distances to nearby points of interest, check-in and check-out times, pet and child policies, extra bed and crib rules, and the order confirmation mode. These fields belong to different dimensions. Some fit structured storage, some are better expressed as tags, and some depend on geographic calculation. Packing everything into one wide table looks convenient at first, but over time it leads to field bloat, an explosion of null values, and rigid queries.

    The first step is therefore to abstract four entity types: the property itself, amenity tags, location coordinates, and policy rules. These entities are linked through stable identifiers, so mutable descriptions are never hard-coded into the property record.

    1. {
    2. "property_id": "p_10086",
    3. "name": "Sample Property",
    4. "address": {"text": "26 Example Street", "lat": 53.81, "lon": -3.05},
    5. "amenities": ["free_wifi", "non_smoking", "beach_access"],
    6. "policies": {"check_in_after": "14:00", "check_out_before": "12:00", "pets": false},
    7. "order_confirm_mode": "on_supplier_confirm"
    8. }

    2. Modeling Amenities and Services as Tags

    An amenity list is naturally a multi-valued attribute. Joining values into a comma-separated string makes indexing impossible and accurate counting unreliable. Two approaches are recommended: a tag table plus a mapping table, which suits scenarios that need backend maintenance and auditing; or an array or tag field paired with an inverted index, which suits read-heavy retrieval scenarios.

    Tag design should follow three rules: use consistent enum values instead of free text; keep a localizable display name for every tag; and distinguish “not available” from “not provided”, so missing information is not mistaken for a negative conclusion.

    3. Location and Distance Calculation

    Descriptions such as “about 3.8 km from the airport” or “about 2.5 km from the amusement beach” are essentially spherical distances from coordinates to points of interest. In engineering terms, store latitude and longitude rather than a text address only. Distance can be computed at query time or precomputed offline, but the calculation basis must be documented, for example the difference between straight-line distance and driving distance.

    For “nearby” filtering, convert coordinates into a grid code for coarse filtering, then run exact distance calculation on the candidate set, balancing performance and precision.

    1. def haversine(lat1, lon1, lat2, lon2):
    2. r = 6371.0
    3. p1, p2 = map(math.radians, (lat1, lat2))
    4. dp = p2 - p1
    5. dl = math.radians(lon2 - lon1)
    6. a = math.sin(dp/2)**2 + math.cos(p1)*math.cos(p2)*math.sin(dl/2)**2
    7. return 2 * r * math.asin(math.sqrt(a))

    4. Structuring and Validating Check-In Rules

    Time-based rules should be split into two independent fields, “earliest check-in time” and “latest check-out time”, using a standard time format with timezone information. Policies for pets, children, extra beds, and cribs are boolean or enum values, and “contact for details” should be modeled as a third state rather than a simple yes or no.

    In the booking flow, these fields must participate in validation. For example, when the crib policy is unconfirmed, any promise-like display such as “crib included” should be blocked to avoid after-sales disputes.

    5. The Order Confirmation State Machine

    “An order takes effect only after confirmation” means an order has intermediate states. A minimal state machine is recommended: pending confirmation, confirmed, cancelled, and expired. Record the actor, time, and reason for every transition to make tracking easy.

    1. pending --supplier confirms--> confirmed
    2. pending --timeout/cancel--> cancelled
    3. confirmed --cancel--> cancelled

    6. Retrieval and Presentation Essentials

    The presentation layer needs to render structured fields into readable copy while supporting multiple languages and localization. For the retrieval layer, build composite indexes on name, address, and tags; apply tokenization and spelling tolerance for fuzzy queries; and combine filters as “tag intersection + distance threshold + policy constraints”.

    7. Data Quality and Observability

    After launch, keep monitoring three metrics: field completeness rate, missing coordinate rate, and the number of abnormal state machine transitions. Logging and monitoring with alerting can establish baselines and trigger alerts on abnormal fluctuations. Data changes should go through a versioned process, keeping historical snapshots to support rollback and review.

    8. Conclusion

    The difficulty of accommodation data lies not in a single record but in unified modeling and consistent validation of multi-source, heterogeneous data. Making amenities taggable, locations coordinate-based, policies enumerable, and orders stateful, and constraining calculation logic with clear documentation, is what supports a stable and extensible accommodation application.