Updating iOS Local Database from server - ios

In iOS, I've had experience working with local-only SQL, and server-only SQL accessed over PHP.
My question is, the app that I'm planning to write will have a local database and a remote database, which is probably pretty common. I'm planning to basically have the iOS app update from certain tables in the server's database.
My question is: Is there a simple or common way to compare the list of columns in a given table, and copy any that are changed or missing from the server to the local database?
Example, if I had a table full of data, and then added a new column on the server, is there a standard way to have the local iOS database reflect that new column?
The idea that I came up with was start both databases as a blank new database, and then any change I add a new SQL script on the server to update the local DB- then, if the iOS device detects a new database revision it would run the update scripts and anything missing would be added. I was just hoping there would be a better way, as this could get messy.

If you use Sqlite in both sides, which would be a zero risk choice for future development, and if you develop a migration system of your own (check Entity Framework Migrations or https://github.com/mocra/fmdb-migration-manager for ideas), you can simply compare latest migration versions and transfer them accordingly. This would be the wisest choice, in my humble opinion.

You should choose webservice for making updates to your iOS app database with Server database. That will be quite easy and efficient way and also Json and xml libraries are powerful way to parse your data. Let me know if you have further queries!

Related

Apple's Cloudkit Migration

This may be too simple of a question for SO, but for those that have used both Cloudkit/Core Data, do you have to migrate data in Cloudkit similar to Core Data if you make any changes to the database itself?
For example, if you adjust your Core Data model at all, you have to go through a migration process in order to make sure the App still works appropriately. Is Cloudkit the same way?
From my understanding there is no migration process necessary (judging when I make changes and run them in the simulator just fine), but I want to confirm before I upload to the App Store. Thanks for any help!
This is covered in detail in the Deploying the Schema section of the CloudKit Quick Start.
The quick summary is that you do need to push changes to production using the CloudKit Dashboard. But keep in mind that you can only make limited schema changes so plan ahead well. You can add new fields. You can add new record types. You can't delete anything.
Keep in mind that users of your app will be using old versions as well as new versions. The latest version of the app will of course know about any new additions to the schema. Old versions of the app won't know about the new fields and record types.

Update iOS database via file or via json?

I'm currently updating an app which I developed quite a long time ago. I'm wondering what's the best way to update the sqlite database via REST api.
I'm thinking about the following process:
When the user is opening the app the device will send the current database version (locally stored in a .plist) to a REST webservice.
The webservice compares the client version to the web version - if there is a new one available I would like to send the entire database to the client (no delta updates).
Now I'm thinking what's the better way to "send" the data to the client. Download a sqlite? Or create a JSON at the webservice (what means somehow overhead). The sqlite is currently about 100 kb.
Anyone an idea?
If
there is no user data to preserve and there won't be any in the future, e.g. if your database is completely static
it is safe to assume its size is not going to increase significantly
your database model hasn't changed and is highly unlikely to change in the future
you're 86% sure that you'll never again be requiring a proper api to a similar online database, featuring delta updates and a generic format like json
go ahead and transmit that replacement sqlite. Otherwise, do it properly!

How do I perform Core Data Migration to an existing app, if all I'm changing is the SQL Db's content?

I've checked a lot of sites and answers and I can't find any solutions specific to my problem.
I don't need to change the schema for my Core data model, all I need is to modify (add some) content to the current backing SQL Database.
Any direction on this will be welcome. Thanks.
PS: I tried Apple docs and they were about as useful to me as sunshine on Mecury.
Also go easy please, I'm a beginner.
Thanks.
UPDATE;
To shed more light on my issue, my app works as thus. I have preloaded static information on the app that can't be changed by the user, each day has new content. Every month, I push an update with entirely new content specific to that month. However, when my app entered production, upon the update I pushed for this month, my users were complaining that they couldn't access the month's data. This led to me spamming them with Push notifications to have them delete the app and do a fresh install to access the new data.
How can I fix this issue? my schema stays the same, only the data changes.
If I understand correctly you want to pre-fill a Core Data database ?
If you don't care about pre-existing data on existing app, you can make an iPhone or Mac app with the same model, and let it generate the database, like explain here (Any way to pre populate core data?) it's also the way recommended in a really great book if you want to learn more about Core Data (http://pragprog.com/book/mzcd2/core-data).
Do not ever make SQL request directly, Core Data work in his own magic way.
Don't work on the SQLite-Database directly. Change all your Data through NSManagedObjectContext! To find a good strategy look up examples from Batch-Importing.
Update: You could actually have two PersistentStores (one with just static data (readonly) and the other one with user-generated data). You could interchange the readonly which you prefilled with a commandline util and downloaded from a server. You cannot have direct relationships between those two store though.
I would say that it depends on the amount of data in this prefilled store wether you should go this way or just use a plist and reference some string constants in your user data store. Try to do it with a plist as this is the simpler approach.

How to Insert data from login form into database table

I am new to blackberry, i am doing application in eclipse,i got an situation, how to insert values into the database when entering the data in the login form which contain 2 fields username and password in blackberry applications, please provide solution.
It's quite difficult to understand what are you asking here.
Do you want to add login form data to a local (mobile) database? Or you want to add it to a centralized (to all applications) server?
In the former case, you need to use BlackBerry APIs to create and populate databases using Persistent Object Store (which is always available for BlackBerry Apps) or use any other database you can separately install in BlackBerry. Also consider using SQLite (integrated with BlackBerry OS 5 or superior).
In the latter case, you need to send login data through HTTP (or any other TCP based protocol) and once data is on you application server, you can insert it on any database it supports: MySQL, PostgreSQL, Oracle, SQLServer, Sybase, you name it.
http://docs.blackberry.com/en/developers/deliverables/8673/JDE_5.0_SQLiteGuide.pdf
DataStorage concept comes here.For this first of all learn how data can be inserted to a database table..The above link is a guide which helps you to learn everything about how table can be created,stored retrieved.
Store the data you entered in a variable viz.username,password using persistent storage..
Use these variable names in the Insertion syntax..

Which database can be used with Xcode and at the same time be populated through a website?

We are trying to create an iPhone application that will automatically receive data from a database. Which is a database that will work with Xcode. Our goal is that users can go to our website and input information. That data will be recorded to a database. Once the user downloads our app, the info should then be retrieved from the database and included in the app. We are wondering what database is suitable. It must be able to receive information from a website AND submit it to an application.
You're unlikely to find a iOS "aware" database that can automatically sync content over the internet.
However, you can of course obtain the data over the internet yourself and then insert it into the local database on the device, in which case the popular (and supported out of the box) SQLite would seem like an obvious choice.
As #Deepak also suggests, you could use Core Data which is a (sort-of, ish) ORM that can automatically use SQLite as it's underlying storage mechanism.
The solution that most people use in this case is to use an RDBMS like MySQL and build a web-service layer on top of the database for the entities that your iPhone app is interested in.
This way, when a user goes to the web-app, they can add the data that you allow them to add there, and later on they can access the same data from the iPhone app via the web-service layer also.
Couchbase's new iOS-Couchbase framework is in beta right now - all the functionality of Apache CouchDB on your favourite developer platform - at https://github.com/couchbaselabs/iOS-Couchbase. the iOS release is new but we're looking for it to go places!
Its awesome sync abilities would allow you to pull down any relevant content from your website via HTTP/JSON, or further formats using shows and lists if needed. Pushing data the other way is just as easy. Sync can be continuous, or on demand, bidirectional or one way.
Take a look at some of the Couch App frameworks (not for iOS but for your website)
http://techzone.couchbase.com/community/articles/couchdb/recipes
http://www.mail-archive.com/user#couchdb.apache.org/msg13928.html lots of comments on this thread
A+
Dave

Resources