1

Introduction: Let me first introduce you to my android app. Its a food-review app which let user to give his/her review of a particular food of a restaurant.

Flow of the app : 1. User launches the app. 2. A list of nearby restaurants pops-up. 3. User selects a restaurant. 4. A list of menu of the selected restaurant is displayed. 5. User selects the food of which he/she wishes to give review/view the rating.

Progress so far: I used Google Place API to get a list of nearby restaurants. But the API does not give a searchable list of foods (menus) of the restaurant.

Issue: The menus, along with the restaurant, are required to be stored in the database along with the reviews of the dishes. If I make one table for restaurants and other table for menus of the restaurant then searching and retrieval time will become very huge.

Need: Can you please tell me how should I design my database so that the retrieval time is as less as micro seconds. Do I need to use some third party app for retrieving records in minimum time possible.

Please reply asap.

2 Answers 2

1

First of all, I would not connect to a database directly from your app. Apps, can be cracked, and the user would have free reign on your database. I would construct a RESTful service that your app will interact with. That RESTful service can then be backended by a combination of a caching layer and a database persistence layer.

As far as the design of the DB persistence layer goes. I personally would probably opt for a NoSQL approach so that you could simply retrieve an object per restaurant and then have access to the menu data for that restaurant, as this frees you to have different data structure for each restaurant if need be.

If however you think that the menu structure for each restaurant will be normalizable such that a relational DB could be used, then feel free to go with that approach. A well design DB schema should be very performant to your needs even if you are querying across multiple tables. Especially if you are using a data cache (memcached or similar) in front of the DB.

The reality is that the in-memory cache is going to be your biggest asset in terms of getting the best overall response times.

Sign up to request clarification or add additional context in comments.

2 Comments

Which will be the best option: 1. Retrieve data from mysql and add it into the sqlite database of the phone. OR 2. store the data in the cache as you mentioned.
I would think that if you want to cache the data on the phone in sqlite, that would be a good approach as well, as then your response time is not subject to the quality of your internet connection. But again, if the data doesn't exist in your local sqlite cache, you would get it through your API (not from MySQL directly)
0

Android apps don't use MySQL -- the overhead would be overwhelming. They use SQLite if they use SQL at all.

See http://developer.android.com/guide/topics/data/data-storage.html for more information on data storage options available through the built-in APIs.

2 Comments

But all the data regarding restaurants and menus will have to be stored in MySQL. I think storing in SQLite is not an option.
@ChanchalKumari What could MySQL offer to an android app that SQLite couldn't do?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.