Firebase Seat Reservation Bus Query

-1

I want to make an application like ADO, to buy your bus tickets to travel, the problem has arisen at the time of making the travel search available on that date, I have thought for hours and can not find the ideal structure to achieve look for several trips on a specific date with your specific price, I mean, you can buy your ticket to go from point A to point D on a given date, but how do I do the database in firebase if there will be occasions where a person will buy a ticket at point B to go to C or from point B to go to D or maybe from point A to go to B, all trips would occupy the same truck, they would be the same date, the same time and so several trips at different times, say that each trip has 1 truck, 1 driver and in a single trip that is made, has various origins and several destinations, each origin destination with different prices. Does anyone recommend a structure to filter the trips well in firebase? I can not think of anything.

    
asked by Eduardo Ricardez 29.01.2018 в 06:49
source

1 answer

0

Remember that Firebase Real Database is a JSON structure, so ehnde could do something like this:

{
    "viajes":[
        "AtoB":{
            "precio":"",
            "disponibilidad":""
        },
        "AtoC":{
            "precio":"",
            "disponibilidad":""
        },
        "AtoD":{
            "precio":"",
            "disponibilidad":""
        },
        "BtoC":{
            "precio":"",
            "disponibilidad":""
        },
        "BtoD":{
            "precio":"",
            "disponibilidad":""
        }
    ],
    "reservas":[
        "01-02-2018":{
            "camionA":{
                "AtoB":"10",
                "AtoC":"5",
                "AtoD":"15",
                "BtoC":"5"
            },
            "camionB":{
                "AtoB":"0",
                "AtoC":"15"
            }
        }
    ]
}

The first node would be something like the list of possible routes of the company, the second node would already record reservations by date and by trucks as well as the routes that occupy reserve in said trucks, of course, there are several ways of doing that structure and improve it but it's a start.

    
answered by 29.01.2018 в 15:13