Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data vs. Database fundamental difference?

Can someone explain to me what the fundamental difference is between Core Data (apparently, a "data store") and a database like SQLite or MySQL?

I am working on writing an iPhone app, and needed a table of static data to display. I thought core data would be a good choice for this, so I got everything set up and functioning as far as the database (i'm sorry - data STORE) went, and then went to try to import my data (it was in an excel file which I exported to CSV). I was thinking it should be a straight forward process like I have done in SQLite and other databases many times, but as it turned out after much research, the only "official" way to do this was to write a parser specifically for my data.

When I asked about this on the Apple Developer forums, the response I got was basically "What kind of idiot are you to think that you could possibly import data directly without having to write code to do it? Core data isn't a database- it's a data STORE!!" For the life of me, though, I can't see the distinction. In every way I have looked at it, core data behaves EXACTLY like a database, with a fancy way of accessing it and enough abstraction that it can use a variety of file formats for actually storing the data. In fact, I was eventually able to import my data using a simple SQLite .import command, so I really don't understand why the concept was so foreign to the responders to my original question.

So what am I missing here? What is so fundamentally different about a data store from a database that makes the concept of simple data importing completely alien to those who know the technology?

like image 620
ibrewster Avatar asked Sep 10 '11 17:09

ibrewster


People also ask

What is the difference between a dataset and a database?

What are the differences between data, a dataset, and a database? Data are observations or measurements (unprocessed or processed) represented as text, numbers, or multimedia. A dataset is a structured collection of data generally associated with a unique body of work. A database is an organized collection of data stored as multiple datasets.

What is the difference between fundamental and core?

is that fundamental is a leading or primary principle, rule, law, or article, which serves as the groundwork of a system; essential part, as, the fundamentals of linear algebra while core is crow. is pertaining to the foundation or basis; serving for the foundation hence: essential, as an element, principle, or law; important; original; elementary.

What is the difference between'fundamental'and'core'?

As nouns the difference between fundamental and core is that fundamental is a leading or primary principle, rule, law, or article, which serves as the groundwork of a system; essential part, as, the fundamentals of linear algebra while core is crow. As an adjective fundamental

Is coredata the best online database solution for You?

However, CoreData is only one of the possible online database solutions. Today, there are a number of third-party frameworks allowing you to do the same. Among them is a very popular Realm database. But what to choose, Core Data or Realm? That's a big question, no doubt! And we'll do our best to figure it out.


1 Answers

Core Data is not simply a means of persisting/storing data to and from disk as is SQL. Core Data's true function is to provide the complete model layer for the Model-View-Controller app design that the Apple API uses. As such Core Data is primarily an object-graph manager with persistence options tack onto the side.

An object-graph is a collection of live objects in memory. In Core Data, these are the managed objects. They are called "managed" objects because the managed object context observes the objects constantly making sure they are in the states and relationships that the data model says they should be in.

Core Data does provide persistence option but exactly what that option is for any particular implementation is largely hidden. You can even use the same data model and managed objects with different persistence methods, sometime in the same app.

The key difference with SQL is that SQL writes the actual data to disk whereas Core Data serializes live objects. When you look at a sqlite store in Core Data you are looking at objects that have been taken apart and "freeze dried". Obviously, "freeze drying" objects requires a rather specific data format in the sqlite store so the Core Data store uses its own custom schema that is largely the same regardless of details of the store.

That is why you can't just swap in any old SQL file and expect Core Data to import it. The SQL file is rows, tables and columns of data and not a specialized tables, columns and rows use to reconstitute freeze dried objects.

Since Core Data is first and foremost an object-graph manager, the only supported and reliable means of importing data is to create the object-graph. In the case of an SQL file, that means reading the SQL data using the SQL api and then generating managed objects from that data and then saving them to a persistent store.

That part is more work but you save time integrating the data into the rest of the app, upgrading the data and gains in reliability and maintainability.

like image 111
TechZen Avatar answered Sep 23 '22 06:09

TechZen