user1685095
user1685095

Reputation: 6121

bare JSON, nosql db or sqlite for android and web app (maybe iOS) for task managment

Sorry for my English, it's not my native language.

I want to develop application with this basic functionality:

  1. User can create tasks with subtasks. Level of hierarcy should be unlimited, so subtasks can have subtasks themselfs and so on.
  2. User can create tags and every tasks can have unlimited level of tags, so user can view all tasks that have been tagged by some tags.
  3. Tasks should be sync with cloud.
  4. It should work fast. So, for example, user wouldn't expirience any lag in transition next level of tasks or in displaying items with different tags.

Well, there is plently of other functionality, like reminders and stuff, but it's not linked to this choice of bare JSON, nosql db or sqlite.

The question is what is more suitable for this functionality?

For example :

  1. In sql we would have to store IDs of subtasks somewhere in schema and do O(n) queries for n level of of hierarchy, but it's rather easy in json. We could have tasks object with array of tasks which is its subtasks. Or in xml (I don't know if that could be done in JSON) we could just have array of some IDs of subtasks) probably. What should I choose, how do you think?
  2. In JSON I could have string items called "tag". And every tasks could have array of tags, pretty simple. In sql I would have to have another table "tags" which would have all tags and all tasks IDs one for each unique pair of tag and ID which is kind of redundant.
  3. Syncing with cloud is easy with JSON. I could just have one big file with all tasks and uploading it from or to server depending where was latest changes (well, basically). But there is two problems. But this way I would tranfering all file, whereas changes were very few and this way app should consume more traffic. Maybe noSQL DB could resolve this? In sql again app could also do that, but it would have to tranfer all db data.

Upvotes: 4

Views: 1548

Answers (4)

neoexpert
neoexpert

Reputation: 469

ThingDB is an embeddable NoSQL database with MongoDB-Like API:

DB db = new DB("./db");
Doc doc=new Doc();
doc.put("name","test");
doc.put("age",31);
db.insert(doc);
//later you can find the saved doc:
Doc d=db.findOne(eq("name","test"));

You can also convert a Doc to a org.json.JSONObject:

JSONObject jo=d.toJSONObject();

https://github.com/neo-expert/thingdb

Upvotes: 0

serv-inc
serv-inc

Reputation: 38207

As this has not been proposed yet, SnappyDB has a very simple API, and is a NoSQL-database for android. It can persist any object (says the website). It is used like so

try {
    DB snappydb = DBFactory.open(context); //create or open an existing databse using the default name

    snappydb.put("name", "Jack Reacher"); 
    snappydb.putInt("age", 42);  
    snappydb.putBoolean("single", true);
    snappydb.put("books", new String[]{"One Shot", "Tripwire", "61 Hours"}); 

    String   name   =  snappydb.get("name");
    int        age    =  snappydb.getInt("age");
    boolean  single =  snappydb.getBoolean("single");
    String[] books  =  snappydb.getArray("books", String.class);// get array of string

    snappydb.close();

    } catch (SnappydbException e) {
}

Storing a serializable object:

AtomicInteger objAtomicInt = new AtomicInteger (42);
snappyDB.put("atomic integer", objAtomicInt);
AtomicInteger myObject = snappyDB.get("atomic integer", AtomicInteger.class);

Storing any object:

MyPojo pojo = new MyPojo ();
snappyDB.put("my_pojo", pojo);
MyPojo myObject = snappyDB.getObject("non_serializable", MyPojo.class);

Upvotes: 0

J Chris A
J Chris A

Reputation: 1034

Couchbase Lite is an embedded native NoSQL database for iOS and Android. It stores JSON documents and transparently syncs them via your cloud servers to other devices, with a security model designed for fine grained access control in multi-user interactive applications.

Github repos here:

Mailing list here: https://groups.google.com/forum/#!forum/mobile-couchbase

Upvotes: 1

Matthew Tyler
Matthew Tyler

Reputation: 326

Here are a few ideas -

couchDB is considered a good type of key-value store for replication across multiple servers/clients. This is probably an appropriate type of database for the problem you are describing.

Otherwise, using any kind of SQL/noSQL style database with a REST access point will work in your scenario. I think MongoDB is a particularly good choice because despite being key/value store it it quick to learn for someone coming from the SQL word - it also returns answers to your queries in json - so if you using something like NodeJS as your REST server it can simplify things a fair bit.

As for general structure of your application - have a look at the docs for asana at http://developer.asana.com/documentation/ - It should give you a good starting point.

Upvotes: 0

Related Questions