While I was new to the ios
technology I always used to avoid sqlite because many of the syntax does not
made any sense to me, so I switched to core data which was beautifully designed
by apple and had various flavors to it, it was far most the easy way by which I
could interact with my applications local database.
I have worked on several
projects where I thought that core data is better and apps where I thought
sqlite is better, but there was a question in my mind which recently got clear
and that was when to distinguish the use of these two technologies.
The answer to this is
quite simple if your application has a relational model of database i.e if it
has primary keys, foreign keys etc then in that case sqlite has
the upper hand and if your application has a non - relational structure then in
that case use core data.
If the app database is
relational then too you may use core data but the handling becomes quite
complicated because you are responsible for handling the business logic (record fetching or adding) for the
database end where this is not the case with sqlite. To be more specific I am
speaking of complicated nested queries and joins.
The hassle in sqlite is
that you have to manually write the database interaction code while this is not
the case with core data maximum of the database interaction code is done by itself,
allowing you to focus on your task.
In sqlite before storing
the database the data needs to be converted to native type c type and same is
the case when you are fetching the data from sqlite. In core data this is
avoided because it will give you fresh objects to bite on since it follows more
oop approach.
There are many classes in core data which helps you to interact with the database and get the results where in sqlite there are c based methods which help you to achieve the same.
Summary: Both are good
technologies but it depends which one you want to pick upon your database
model.
I hope this post has helped you in choosing the best technology for your app, and if you have any queries then mail me or post it as a comment.
Happy iCoding
Comments
Post a Comment