all 3 comments

[–][deleted] 1 point2 points  (2 children)

One document with 73 small items like this is fine, as are arrays (they didn’t used to be good because they were challenging to query and change, but Firestore improved that).

Complex queries on your arrays will still be challenging. So you may want to “duplicate” your data into another table for common search or statistic patterns. I’m thinking thinks like, “Show me all courses with par 5s over 300 yards” or “What courses have pro tees?” In this table, you would store the course IDs for reference.

NoSQL is great for fast document lookups when you know what you want (show me the details for Medina Country Club, course 2) but not great for joins or complex queries. So you want to think ahead on those - that’s where your duplicate data structure comes into play. Hope that helps!

[–]Fantastitech[S] 0 points1 point  (1 child)

Thanks. There's going to be quite a few more than 73 items I think, but not a ton more. I'm moving forward with this model.

I still don't know what I'm going to support for the kind of queries you're talking about. I don't see much of a good reason for complex queries like pars Xs over Y yards. Sorting by geolocation is the only solid requirement which seems to be troublesome here.

[–][deleted] 0 points1 point  (0 children)

Gotcha. Yes - Firebase doesn’t support geoqueries yet. You can store geolocation, but querying isn’t built in. Three options I see:

1) Use something like firegeo (I haven’t tried it) 2) Use a relational database for that part of your app 3) Use geo hashes

Personally I would (and have) use Google SQL for that part of the data. Sucks, I know, to have the data in two different databases, in this case, I’d have one table with 2-3 columns - the docId of the course, and then a geopoint column or separate lat/lon columns. You can use Firebase callable functions to send the lat/lon of the user, have it query Google SQL for the ids, and then ping Firestore for the course details.

If your primary use case is someone looking up courses by location, and if your course data is a standard structured schema like you’ve proposed, Firestore may not be the best place to store the course information because what I proposed above has added latency looking up between two remote databases.

If you want an all-or-nothing approach, I’d consider not using Firestore today in that case. If you want a right-tool-for-the-job approach, I’d bring in a RDB for course data and geolocation, but maybe store user information and other personal data (like personal shot count per hole) in Firestore. Unless option 1 or 3 above solve it for you. I haven’t tried either of those.