Rory Lester
Rory Lester

Reputation: 2918

iphone retrieving specific data from mysql database

I want to make an application however i am unsure on the best approach to retrieve data from the database. For example, my application will display 'Student Names', 'Scores' and 'Country of Origin'. The data will be stored in a remote mysql database.

Problem - In my application the users will have an option to display students with a specific 'country of origin'.

My usual approach is to use JSON to parse information from the database to the iphone but this means that the iphone will have to download ALL the records from the database and then i can predicate the data according to the 'country of origin' that the user selects.

Problem is i have hundreds of records. Downloading all of them means that i am wasting resources? what other ways are there to tackle this problem (so that the user only downloads the records that match his criteria instead of all of them)?

Upvotes: 0

Views: 205

Answers (1)

Michael Frederick
Michael Frederick

Reputation: 16714

You should create an API for the app to interact with using a server side programming language. Your API should do the searching -- meaning that it should be the one to find all students in your 'country of origin'. The app can pass the API the 'country of origin', the server can perform the SQL query to select the correct responses, and then the API can present the app with only the data that the app needs. Using JSON is the way to go.

Upvotes: 1

Related Questions