2

I was learning Core Data and previously I have used SQLite in one of my projects. My question is, what scenario should I use Core Data vesus SQLite? I've read some of the advantages of Core Data, that it provides visual way to design data structure, abstract level of accessing data and SQLite can be use on multi platform but is there anything related to data size? That if data size is large than we should use Core Data or vice-versa?

Chris Knadler
  • 2,819
  • 2
  • 26
  • 32
Nuzhat Zari
  • 3,398
  • 2
  • 24
  • 36
  • possible duplicate: – pasawaya Jun 26 '12 at 19:30
  • 3
    I do not know why my question is downvoted, because my question was the scenarios where we can use Core Data and SQLite and I didn't find it anywhere so I asked.And the link you have suggested also shows advantages of Core Data in graph but no where it has mention in which cases we should go for Core Data or SQLite if graph is not the requirement. Or can say this is one of the scenario which shows we should use Core Data where graph is the required.Please those who are down voting give their comments also because I want to know what is wrong. – Nuzhat Zari Jun 27 '12 at 05:04
  • I am looking for this answer too, I have been asked this same question in interview. So I would like to know the answer if moderator allows it as a constructive question. Please do. – Sanoj Kashyap Jun 15 '15 at 17:30

4 Answers4

6

Core Data:

  1. Primary function is graph management (although reading and writing to disk is an important supporting feature)

  2. Operates on objects stored in memory (although they can be lazily loaded from disk)

  3. Works with fully-fledged objects that self-manage a lot of their behavior and can be subclassed and customized for further behaviors

  4. Non-transactional, single threaded, single user (unless you create an entire abstraction around Core Data which provides these things)

  5. Only operates in memory

  6. Requires a save process

  7. Can create millions of new objects in-memory very quickly (although saving these objects will be slow)

  8. Leaves data constraints to the business logic side of the program

Database or SQLite:

  1. Primary function is storing and fetching data

  2. Operates on data stored on disk (or minimally and incrementally loaded)

  3. Stores "dumb" data

  4. Can be transactional, thread-safe, multi-user

  5. Can drop tables and edit data without loading into memory

  6. Perpetually saved to disk (and often crash resilient)

  7. Can be slow to create millions of new rows

  8. Offers data constraints like "unique" keys

Referred from below link http://cocoawithlove.com/2010/02/differences-between-core-data-and.html

Thiem Nguyen
  • 6,345
  • 7
  • 30
  • 50
ABC1
  • 116
  • 7
  • Thanks for your reply but my question was not comparison between Core data and SQLite.I want to know the scenarios. – Nuzhat Zari Jun 27 '12 at 05:13
  • @NuzhatZari: The comparisons tells you the scenarios. E.g. You want/need multi-user? Then you use SQLite, since this feature comes for free and would have to be implement it for CoreData first. Or you are dealing with data larger than would fit into memory? Then CoreData would be no option, SQLite would be an option. – Mecki Oct 09 '12 at 14:49
0

There is no limitation of data amount for Core Data - in fact, it uses SQLite as a store, so the data size shouldn't bother you.

Core Data is a really great solution, so i suggest you to use it in your project.

Nikita Pestrov
  • 5,876
  • 4
  • 31
  • 66
0

For large data (more than 100000 records) with more "many to many" or "one to many" relationships between entities in this case you can use SQLite otherwise you can go for core data without any issue.

Also one more suggestion, please normalize your database before going to take any decision.

To handle large data using SQLite, There is a very good tutorial Improve INSERT-per-second performance of SQLite?

Community
  • 1
  • 1
ABC1
  • 116
  • 7
0

In my experence the the data size was never an issue, but I have heard that SQLite is more robust. I've gone with SQLite because we wanted our app to be pre-populated with data for the user, and with Core Data it is meant for a single user that will populate it things like an address book.

DROP TABLE users
  • 1,955
  • 14
  • 26