Travel app data model

Travel app data model

The data model for the travel app uses several distinct document types: airline, route, airport and landmark.

The model for each kind of document contains:
  • A key that acts as a primary key
  • An id field that identifies the document
  • A type field that identifies the kind of document

The following figure illustrates the relationship between the different kinds of documents. It shows the primary key, ID, and type fields that each document has, plus a few representative fields in each type of document.

Figure 1. Documents in the travel app data model

Airline documents

Airline documents contain details about airlines such as the name of the airline, International Air Transport Association (IATA) two-character airline designator, International Civil Aviation Organization (ICAO) three-character airline designator, and the airline call sign.

For airline documents, the value of the type field is airline.

Airline document model
airline_24 			   ←This is the key, which also acts as a primary key
{
    "active": "Y",
    "callsign": "AMERICAN",
    "country": "United States",
    "iata": "AA",
    "icao": "AAL",
    "id": "24",
    "name": "American Airlines",
    "type": "airline"              ←This is the type identifier for the document
}

Route documents

Route documents contain details about flights such as the name of the airline, departure airport, destination airport, number of stops during the flight, type of aircraft, flight number, and flight schedule.

Route documents also contain a foreign key identifier, airlineid, that is used to retrieve the document that contains information about the airline that flies the route. The value of the airlineid field is identical to the key for the corresponding airline document.

For route documents, the value of the type field is route.

Route document model
route_5966                         ←This is the key, which also acts as a primary key
{
    "id": "5966",
    "type": "route",               ←This is the type identifier for the document
    "airline": "AA",
    "airlineid": "airline_24",     ←This is the foreign key identifier to an airline document
    "sourceairport": "MCO",
    "destinationairport": "SEA",
    "stops": "0",
    "equipment": "737",
    "schedule": [
        {"day": 1, "utc": "13:25:00", "flight": "AA788"}, 
        {"day": 4, "utc": "13:25:00", "flight": "AA419"},
        {"day": 5, "utc": "13:25:00", "flight": "AA519"}
    ]
}

Airport documents

Airport documents contain details about airports such as name, location, time zone, ICAO four-character alphanumeric airport code, and Federal Aviation Administration (FAA) location identifier.

For airport documents, the value of the type field is airport.

Airport document model
airport_3577                       ←This is the key, which also acts as a primary key
{
    "travel-sample": {
        "airportname": "Seattle Tacoma Intl",
        "city": "Seattle",
        "country": "United States",
        "faa": "SEA",
        "geo": {
            "alt": 433,
            "lat": 47.449,
            "lon": -122.309306
        },
        "icao": "KSEA",
        "id": 3577,
        "type": "airport",         ←This is the type identifier for the document
        "tz": "America/Los_Angeles"
    }
}

Landmark documents

Landmark documents contain details about points of interest such as hotels. They include information such as name, location, price, contact information, and the kind of activity that the point of interest provides.

For landmark documents, the value of the type field is landmark.

Landmark document model
landmark_21661                     ←This is the key, which also acts as a primary key
{
    "activity": "sleep",
    "address": "12 Rue Boulainvilliers",
    "alt": null,
    "checkin": null,
    "checkout": null,
    "city": null,
    "content": "Small three star hotel (33 rooms).",
    "country": "France",
    "directions": null,
    "email": null,
    "fax": null,
    "geo": {
        "lat": 48.853,
        "lon": 2.27593
    },
    "hours": null,
    "id": 21661,
    "image": null,
    "name": "Hotel Eiffel Kennedy",
    "phone": "+33 1 45 24 45 75",
    "price": "~\u20ac150",
    "state": "Ile-de-France",
    "title": "Paris/16th arrondissement",
    "tollfree": null,
    "type": "landmark",            ←This is the type identifier for the document
    "url": "http://ww.eiffelkennedy.com"
}