Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why core data is not an ORM

I have read that Core Data is not an ORM? Can anybody please list out the point that why it is not an ORM?

My Point:

  1. While using Core Data we work mainly on objects same as in ORM.
  2. All the access and manipulation is done on objects.
  3. We can change the backend and it support multiple backend like sqlite, plist, in-memory.
like image 678
Saurav Nagpal Avatar asked Oct 21 '16 13:10

Saurav Nagpal


People also ask

Is Core Data an ORM?

Core Data: Apple's ORM Framework for iOS and the Mac.

What type of database is Core Data?

Core Data is not a database. Core Data is a framework for managing an object graph. An object graph is nothing more than a collection of interconnected objects. The framework excels at managing complex object graphs.

Why Core Data is faster than SQLite?

Core Data is heavily optimized with regards to caching, lazy-loading and memory management. If you use it (with the SQLite store type), especially in conjunction with NSFetchedResultsController, you should get better performance than you could get with SQLite on your own.

Is SQL an ORM?

ORM and SQL are two tools available that web developers can use in database management. When comparing them, SQL has a higher hands-on management than ORM. Because ORM has a higher level of abstraction and more complexity than SQL, less hands-on management is required; this makes data management more efficient.


1 Answers

Short answer: CoreData is more than ORM implementation.

Long answer:

ORM wikipedia definition is:

Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language.

Put it simply, it's just an abstraction, or virtualization of a relational persistence layer that eases the effort to access and write to/in it. (Note: object-relational mapping)

While CoreData definition states:

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.

Coredata definition does not mention to stick with ORM definition, eventhough it seems fully compliant.

The difference I found is: since CoreData framework separates its abstraction layer (Managed Objects and Managed object contexts) from its persistence layer (Persistence Store) through its Persistence Store Coordinator, it can abstract objects from a relational-database, as sqlite, aswell as from any other not relational persistence layer.

To support this statement, here NSHipster brief description:

Contrary to popular belief, Core Data is not an Object-Relational Mapper, but rather an object graph and persistence framework, capable of [...]. Using Core Data as an ORM necessarily limits the capabilities of Core Data and muddies its conceptual purity.

like image 77
Biasu Avatar answered Nov 03 '22 07:11

Biasu