Reputation: 141
I am developing a hybrid app with Ionic. Currently I am using sqLite (relational) as I come from a MySQL background.
As I need to sync my database quite frequently (usually after each change - either in the app or on the server) I was looking for some solution before investing time to create my own service (do not reinvent the wheel).
I came across a nice tutorial from Nic Raboy (https://www.youtube.com/watch?v=erQMOUcAdXk) where he explains how to use PouchDB for easy syncing.
So far so good - but I could not yet figure out if or how I can use PouchDB with my existing sqLite database or if I have to switch entirely to a NoSQL database.
In case I have to switch to NoSQL I have the next issue: How do I have to design my "relations" in a NoSQL db?
Let me ask in detail:
I have a SQL statement to retrieve data from 2 or more tables like this:
SELECT c.title, c.info, ruc.active
FROM app_user u
INNER JOIN rel_user_categories ruc
ON ruc.uid = u.id
INNER JOIN app_categories c
ON c.id = ruc.cid
or this:
SELECT av.venuename, av.latitude, av.longitude, ao.title, ao.info, ao.beacon
FROM app_offers ao
INNER JOIN app_venues av
ON av.id = ao.venue
WHERE ao.active AND av.active
ORDER BY ao.expires ASC
Is there a way to fire some queries that do exactly the same if I use NoSQL? I was using Google now since about 1 day and did not come across any solution.
Thanks in advance for your help!
Upvotes: 2
Views: 2019
Reputation: 2419
Concerning your first question:
So far so good - but I could not yet figure out if or how I can use PouchDB with my existing sqLite database or if I have to switch entirely to a NoSQL database
You can only sync with a database that uses the same sync protocol. That would be one of these:
Your second question is very general. You need to read up on structuring data in JSON documents and the differences to relational databases. It is a different world and you will have to spend some time on this so do read up.
This is same if you would use MongoDB (which can't sync but is used more often than CouchDB so you might find helpful articles written for Mongo).
Learning data structuring for JSON documents and querying CouchDB will take some time. But it is certainly worth it if you need the syncing. No other database can compare in this regard.
Upvotes: 3