Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use MongoDB as a replacement for CoreData on iOS?

Tags:

I'm just starting to read up on NoSQL technologies such as MongoDB and CouchDB. I'm interested in knowing whether I can use MongoDB or indeed any NoSQL technology as a replacement for Core Data applications.

Core data applications can take a long time to learn and implement, especially if your app is complex and you just want to do some simple add, edits, deletes and queries (CRUD stuff).

Because it looks like JSON and looks like it can run really fast; I'm interested in the implementation of NoSQL over Core Data.

Can I run MongoDB as native? I did some Google searches but wasn't really able to get the specific answers I'm after.

Such as:

I am not sure what the remit is for NoSQL on iphone platforms, is it supported, would it be denied by the Apple team if I submit an app with NoSQL on it?

Thanks

like image 771
zardon Avatar asked Mar 02 '11 19:03

zardon


People also ask

Does MongoDB work with iOS?

MongoDB Mobile is a version of MongoDB which is embeddable in applications on Android, iOS and other systems.

Should I use realm or Core Data?

Core Data is incredibly fast if you consider what it does under the hood to do its magic. But Realm is faster, much faster. Realm was built with performance in mind and that shows. As Marcus Zarra once said in a presentation, you don't choose Core Data for its speed.

For what kind of applications MongoDB is not suitable?

MongoDB would not be well suited for applications that need: Multi-Object Transactions: MongoDB only supports ACID transactions for a single document. SQL: SQL is well-known and a lot of people know how to write very complex queries to do lots of things.

What is Core Data in iOS?

Core Data is a framework that you use to manage the model layer objects in your application. It provides generalized and automated solutions to common tasks associated with object life cycle and object graph management, including persistence.


2 Answers

As an aside, I will note that it's a common misperception but Core Data is not a database system.

Instead, it is a runtime object graph management system with persistent tacked on as option if you want it. It's primary function is to provide the model layer of the Model-View-Controller design pattern. As such, it deals with a lot more than just getting data on and off a disk.

Core Data does have a learning curve but in my experience the biggest obstacle many face is trying to treat Core Data as some kind of object oriented wrapper around SQL. From that perspective Core Data is very confusing because it seems to require to learn so much that has nothing to do with persistence.

Using database like SQLite, MongoDB and CouchDB for persistence won't really speed things along at all because, although you might better understand how they get data on and off the disk, they won't help at all in managing the data and the relationship to the other data objects and the objects of the UI. You still have to have a data model and you will have to code all that up by hand. Unless your data model is extremely simple, that will take more time than learning Core Data.

The best way to learn Core Data is to ignore the fact that the object graph can be persisted at all. Just start from the perspective that you've got a lot of objects that represent the data model of you app and you have to manage their attributes and relationships.

like image 164
TechZen Avatar answered Nov 08 '22 19:11

TechZen


MongoDB is probably not a good fit here. The server assumes that disk space is not a limiting factor. The current stabel brance (1.6.x) does not provide data durability on a single instance. It also uses memory mapped files which are fine on dedicated servers but will cause lots of disk churn and unnecessary memory use on a typical PC. I have no experience with Core Data, but it sounds like a septate niche to me.

like image 36
John F. Miller Avatar answered Nov 08 '22 20:11

John F. Miller