Which database should you use to program an iPhone/iPad application? - iphone

I am new to iPhone development and want to know which database you use to program an iPhone/iPad?
I have heard its SQLite, are there any alternatives to this?
The application I am programming is like an online shop however you can't buy products, only view their details.

You should use CoreData for that. CoreData is a database abstraction layer which uses SQLite to store your data. Or you could use SQLite directly. But I would prefer CoreData.
Core Data Programming Guide
Core Data Overview

If you have any plan to use the database file outside iPhone e.g. in other computer, or data input program to populate data, then SQlite is the best choice. CoreData modify the fields name when you create the database inside XCode. But if the data is only accessed by your app in the iPhone, best choice is CoreData.
If you want to run complex sql query then sqlite is better. Read about NSPredicate, what type of query you can do there.

SQLite is the master choice here!
As an alternative, I would suggest you the simplicity of an XML file.

You can also use NSUserDefaults if u have less data to be stored in your database.
http://icodeblog.com/2008/10/03/iphone-programming-tutorial-savingretrieving-data-using-nsuserdefaults/
If the data to be stored is more then go for sqlite

Related

Use txt files or sqlite with core data in project?

I am developing iPhone app for a web application currently running online. Current web application is big and complex and uses SQL to store vital information like member details, login credentials etx. Other stuffs like info about several sections, groups, sub groups and other information related to each are saved in txt. Current system uses its own standard to keep data in files and also made custom algorithm to read and write data in it. Each txt file is below 1 mb size. There are lot of data manipulations going on.
Custom algorithm created just read those files and put all data in cache as records (same as in core data managedobjectcontext) and whenever there is a change in data the whole file is overwritten.
So while implementing the same what I want to choose for iPhone app? In apple website they said that 'SQLite is perfect for low-level relational database work' https://developer.apple.com/technologies/ios/data-management.html But in my case it is high level.
So please help me to make a decision. Do I want to manage data in files or sqlite database using core data?
I would also like to know whether it is possible to import those classes and algorithms currently in webserver to iOS, so I don't want to rewrite the same algorithm for iOS? Current server codes are in C#
In the rare case that you need to do low-level relational database work use SQLite. In the 99% other cases use Core Data. Don't ever store relational stuff into txt files. It'll just be a pain.
Your use case sounds like a good match for Core Data.
Often misunderstood, Core Data is an object store that happens to use sqlite for persistence. You don't manipulate the sqlite underneath it, Core Data manage the sqlite for you. You do not write SQL. The closest match to it in .NET is EDM and the Entity Framework in ADO.NET.
Assuming the classes and algorithm you want to import in the webserver is in C#, sadly those needed to be ported to Obj-C.

How to Create Sqlite database for IOS Application in efficient way?

I have built an android app and now its time to built an IOS app. I am very new to IOS App development. I managed to done all the UI design parts and i am coding the backend part. In my application i am using Sqlite database and has many View Controllers each View talks to database. So i would like to have one Class(Java) which take care about the creating,inserting,deleting etc. If i need to get data from database then i have to call that class to access the database. Is there any way to do like this.
Or
I would like to know how to create sqlite database in a efficient way. Because my app fully based on database.
Thanks for your help guys.
There are two main ways to create a database:
Use CoreData. In this case you should read manuals on CoreData, it is pretty complicated. But if you plan to use iCloud in future, I recommend you to use CoreData.
Create db manually and not use CoreData.
The most efficient way in second case is to use a database manager for SQLite. For example, SQLite manager extension for Firefox.
There are more programs for this, but this is free one, that I use myself.
To work with database use FMDB wrapper over SQLite.
Nice tutorial for second approach.

Using SQLite on the iPhone: do I have to read the entire database and store it into an array?

Hi I am a newbie to iPhone programming. I have been looking at some tutorials online for using SQLite on the iPhone.
From what Iv'e seen, one has to read the entire database in the app delegate method and then store the contents in an array. This is then used to populate a UITableView.
I was wondering how this can be efficient? I mean, if you are going to store the contents of your entire database in memory why have a database?
Is this standard practice?
Instead of this, if I use Core Data, I can set the paging size and it will optimize how much data is stored in memory and only read whats being shown within the visible cells.
Is there anyway, In can have the same functionality using SQLite? so its easy on memory. I mean my database has only 300 entries now, but what if in the future it has 3 million?
Can some one please assist me in understanding this....
Are there any tutorials for SQLite that show how to do it in an optimized way?
Thanks
I would suggest using Core Data. It's extremely powerful, better supported than a SQLite table, and not as complicated as it looks, it just uses a lot of "managed object" jargon which can be daunting at first. Check out the CoreDataHelper class, and a few tutorials. I was able to get Core Data working in a few days (in my first ever app) using the links in my comment
If you're familiar with SQL, basically Core Data works like this: the Persistent Store IS a SQLite table, but you never access it directly; the managedObjectContext is where you do all the data work in your program (and don't forget to save it to the persistent store!), while an Entity is a table, attributes of that entity are your columns, and a managed object is a row.
Further Reading:
Core Data Tutorial - YouTube
Core Data Tutorial: Getting Started | Ray Wenderlich
iPhone Core Data: Your First Steps
Here is some tutorial that may help you:
iPhone Programming Tutorial.
I recommend you consider using core data instead of sqlite.

core data - how to use?

I want to build an app that uses core data, but all the tutorials I found in the net didn't show if I can store a data without using the code it self.
Is there anyway to do it?
For example, i want to make a row of name and put there couple of names.
I've just read the book "Pro Core Data for iOS" from APRESS it covers Core Data very well. I recommend this by heart.
You can try Core Data Editor. But it's not cheap.
You can use SQLite directly without Core Data; there you'd have your SQLs in your own hands. Your can use Core Data and debug SQLs issued by the framework, of course if using SQLite as the store.
Core Data works also with binary and XML format (the latter not available on iPhone): passing following argument to the application:
-com.apple.CoreData.SQLDebug 1
Other than that, you could probably use SQL to access Core Data SQLite store, since it is all SQL, but it is not recommended.
Unfortunately Core Data is all code. However, CoreData is an api that helps you create, save, load data from the database, it uses SQLLite in an easier fashion.
If you need very complex data storage then by all means use SQLLite directly. But, if it's just simple data storage of names, emails, booleans, etc, then i would recommend CoreData.
I'll give you a link that it helped me greatly when i wanted to integrate CoreData for my app.
CoreData Tutorial
Good Luck.

is sqlite is better or plist is better to save and edit items

i am trying to develop a simple application like shopping list.
for that i have 20 categories in that 250 item names.
for that i found two ways to save these item names and it's respective values one is using sqlite data base,another one is plist.
and i need to edit these item quantity and need to add new item to category.
for that which way is better for my application.
experts who have familiar with sqlite data base and plist can suggest which way is better.
thank u in advance.
My feeling is that SQLite is the better tool for this job, especially when the data grows. That's because with a PList, you have to completely load it into memory whereas with SQLite you only fetch the data you need. Of course, programming for SQLite is a little bit more work but if you encapsulate that in a class it can be as easy to use later on.
Using of SQLite would be suggested.
If you are doing more transaction over the database then use SQLite instead of plits.
If it is client- server modal, have a database of SQL or Oracle at the back end. Store the data which is frequently used at the client side using SQLite ans sync it regularly with the database
regarding sqlite tutorial
http://dblog.com.au/iphone-development-tutorials/iphone-sdk-tutorial-reading-data-from-a-sqlite-database/