'How Can I Use Data More Efficiently (Economically) With Firebase? [closed]

How can I use the database efficiently (economically) when fetching data after Firebase has saved new data?

There is a table of cars with models and characteristics of cars. The user will create a list in the My cars table and add the cars he has.

Should all properties be added to the my cars table or should they be added only by adding the ids of the cars and placing a request to those ids with the help of a loop?

cars.json

{
    "-MxOq5xYjYpZjOYviQQa": {
        "color": "red",
        "hp": "150",
        "title": "Auidi A1",
        "type": "DSG"
    },
    "-MxOqAAtRU06ZE04djoB": {
        "color": "black",
        "hp": "200",
        "title": "Auidi A2",
        "type": "DSG"
    },
    "-MxOqN-1BpR2DLlucZ1J": {
        "color": "white",
        "hp": "250",
        "title": "Auidi A3",
        "type": "DSG"
    }
}

1.Usage (list.json)

{
    "title": "My Car",
    "desc": "Cars I own.",
    "userId" : "1213",
    "cars": {
        "-MxOq5xYjYpZjOYviQQa": {
            "title": "Auidi A1",
            "color": "red",
            "hp": "150",
            "type": "DSG"
        },
        "-MxOqAAtRU06ZE04djoB": {
            "title": "Auidi A2",
            "color": "black",
            "hp": "200",
            "type": "DSG"
        }
    }
}

2.Usage (list.json)

{
    "title": "My Car",
    "desc": "Cars I own.",
    "userId" : "1213",
    "cars" : ["-MxOq5xYjYpZjOYviQQa","-MxOqAAtRU06ZE04djoB"]
}

Note: There is more attribute data in the Cars table.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source