Help with Understanding Core Data

Could someone please explain this. Are SQLite and CORE DATA two different technologies? I was under the impression that a SQLite database is created in your app when you create a core data app, and that you use the core data api to access it?


Also, I have struggled to find information on learning SQLite or Core Data with swift and xcode 7. Would anyone have any suggestions for books etc to understand it all. How do people learn this stuff. Do most people just use the Apple tutorials and docmentation.


Sorry if I'm sounding like I'm scrambling/clawing for knowledge. I am


Dave.

Answered by junkpile in 64350022

The default backing store used by Core Data is indeed SQLite, but the API completely encapsulates that. So from an app programming perspective there is only Core Data. You never construct SQL queries, iterate result sets etc. - you use the Managed Object API that Core Data supplies. The fact that it uses SQLite under the hood is irrelevant. They (or you) could change it to a different backing store if you want and it should not affect your app code.


No idea how people learn Core Data. 🙂 I haven't tackled it myself. So far I've just used SQLite directly (well, using the FMDB wrapper) with good results. I've been using SQL off and on for ~20 years so it's not a big jump for me. If you are starting from scratch then Core Data, even with its steep learning curve, is probably a better way to go.

Accepted Answer

The default backing store used by Core Data is indeed SQLite, but the API completely encapsulates that. So from an app programming perspective there is only Core Data. You never construct SQL queries, iterate result sets etc. - you use the Managed Object API that Core Data supplies. The fact that it uses SQLite under the hood is irrelevant. They (or you) could change it to a different backing store if you want and it should not affect your app code.


No idea how people learn Core Data. 🙂 I haven't tackled it myself. So far I've just used SQLite directly (well, using the FMDB wrapper) with good results. I've been using SQL off and on for ~20 years so it's not a big jump for me. If you are starting from scratch then Core Data, even with its steep learning curve, is probably a better way to go.

junkpile:



Thanks for the response. I didn't realize that Core Data was a db system in itself. I am a long time .NET/SQL Server/Entity Framework developer learning IOS App development. My goal is to create business app's where a user can store records on the device (when no internet connectivity exists) and then upload to a SQL server database later.


Thanks

Apple is very adamant that Core Data is NOT a database. You need to read some of the documentation about what core data is and how to use it. Going into it with the idea that it is another DB will lead to frustration and a much longer learning curve as you try to apply DB concepts to Core Data.


Frank

sqlite is the most widely used SQL database in the world. It ships on every cell phone and probably every personal computer. The source code fits into one C source code file. You can learn more about it at sqlite.org. Apple ships a version of sqlite on iOS and Macintosh that has been optimized for use on those computers. Use the FMDB Objective-C wrapper for sqlite if you want to do SQL programming on iOS.


Core Data is an Apple technology that is an object store. It's a lot like a relational database with Entities and the standard relationships between entitites. sqlite is one of the available backing stores for Core Data. In reality there's probably no reason to use Core Data unless you're going to use sqlite as the backing store. I would recommend using the Core Data tutorials at www.raywenderlich.com to learn how to use Core Data.

Help with Understanding Core Data
 
 
Q