Firebase queries impossible to work without JOINS/Multi WHERE clauses

1,589 views
Skip to first unread message

niztal

unread,
Nov 17, 2016, 8:02:09 AM11/17/16
to Firebase Google Group, Uri Brodsky
our main DB structure looks like this:

1. Users.
2. Companies.
3. Companies Posts.
4. User_Companies
5. User_Likes

The issue is that we cannot do JOINs, even if we denormalize the data, things get complicated, since we need to join it with the current user's companies list, take the data paginated and order it by date.

We already thought of building a background script which denormalize the data for each user and builds him a user_feed on each change (like/unlike/new post published/post removed/etc.) but it was very very heavy CPU/RAM process which caused a lot of issues and finally didn't work in a large scale of users and companies.

Moreover, we noticed that we able to filter our data only by one field (no multi WHERE CLAUSES), now for example we'd like to filter out posts that were already like/unliked by the user, paginated it, order by date and JOIN with user's companies.

 
We already started thinking of moving our application to a new hosted server on cloud and build our own infrastructure :( with SQL DB so we can make some relational queries, but before that we need someone to guide us maybe there are other options, to still stay with a firebase solution.


Thanks,
Nitzan.

Kato Richardson

unread,
Nov 17, 2016, 3:07:41 PM11/17/16
to Firebase Google Group
Hi Nitzan,

This topic has been hashed out multiple times here and on Stack Overflow. Coming from an RDB background myself, I hear your frustrations. But NoSQL is just a different kind of beast--it scales wonderfully and is fluid and fast to build on, trading out SQL capabilities to get these advantages.

Also, it's not particularly hard to form your own joins, or to avoid them altogether. The NoSQL mantra is to work hard on writes so reads are easy. See NoSQL modeling techniques (highly recommended).

But if you do need to do a join, here's the basic idea, and here's how you query using multiple criteria. If you need to dynamically search on unpredictable criteria, then you want to integrate a proper search tool.

Here are a few other things to check out before you burn years building your own real-time infrastructure:
Blog on SQL queries in Firebase (a bit outdated but useful)
Flashlight (full contextual search integration via ElasticSearch)

I hope that helps!

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/ece1e792-41d2-4c73-b8ba-9a5896792679%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

niztal

unread,
Dec 4, 2016, 6:44:24 AM12/4/16
to Firebase Google Group
Thanks Kato, it did help a lot.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/ece1e792-41d2-4c73-b8ba-9a5896792679%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages