0
votes

I have a simple question. I have a card object and in that card object i have an arraylist of Strings called "tags." There are two ways I can store the tags.

  1. I can put all the tags ("food,"dessert,"drink") into one string object, and query that object and parse the individual tags at the ",".
  2. I can put all the tags into an arrayList of strings and then query that arraylist of strings and not have to parse. But here, Firebase creates an extra key and slot for each object in the tags arrayList. I'm not sure if that matters.

Which one is a more efficient method of storing and retrieving data?

1

1 Answers

0
votes
  1. I highly wouldn't recommend that.
  2. More cleaner approach than the first. You shouldn't worry about the extra keys/objects.

Besides that I would recommend a structure like that:

- cards
  - [cardID]
    - ...
    - tags
      - food : true
      - dessert : true
      - ... : true

Check out the Firebase Guide for Structuring Data for the more in detail explanation of my recommendation.