Ans : Core-data is not database that we understand. Sqlite is Database.
Lets have a look over difference between Core-data and Sqlite (or Database) :
Core Data:
Database or SQLite:
Lets have a look over difference between Core-data and Sqlite (or Database) :
Core Data:
- Primary function is graph management (although reading and writing to disk is an important supporting feature).
- Operates on objects stored in memory (although they can be lazily loaded from disk).
- Works with fully-fledged objects that self-manage a lot of their behavior and can be sub classed and customized for further behaviors.
- Non-transactional, single threaded, single user (unless you create an entire abstraction around Core Data which provides these things).
- Only operates in memory.
- Requires a save process.
- Can create millions of new objects in-memory very quickly (although saving these objects will be slow).
- Leaves data constraints to the business logic side of the program.
Database or SQLite:
- Primary function is storing and fetching data.
- Operates on data stored on disk (or minimally and incrementally loaded).
- Stores "dumb" data.
- Can be transactional, thread-safe, multi-user.
- Can drop tables and edit data without loading into memory.
- Perpetually saved to disk (and often crash resilient).
- Can be slow to create millions of new rows.
- Offers data constraints like "unique" keys.
Credit : http://www.cocoawithlove.com/2010/02/differences-between-core-data-and.html
Advantage of Core-data :
- Much better memory management. With a plist you must load the entire thing into memory; with Core Data only the objects you're currently using need to be loaded. Also, once objects are loaded, they're normally placeholder "fault" objects whose property data doesn't load until you need it.
- Related to the above, when you have changes, you can save only the changed objects, not the entire data set.
- You can read/write your model objects directly instead of converting them to/from something like an Dictionary.
- Built-in sorting of objects when you fetch them from the data store.
- Rich system of predicates for searching your data set for objects of interest.
- Relationships between entities are handled directly, as properties on the related objects. With a plist you would need to do something like store an object ID for a relationship, and then look up the related object.
- Optional automatic validation of property values.
More about Core-data :
- CoreData isn't a Database. It's an object persistence layer. There is no concept of primary keys or foreign keys in CoreData.
- If you want to establish a relationship between two entities. You'll define a relationship, CoreData takes care of how that relationship is stored.
- Select an entity, use plus button at the bottom of the entities attributes list, select add relationship, select the destination entity from the dropdown.
- Select the destination entity and define an inverse relationship in the same way.
Great
ReplyDelete