-2

I want to develop a Nutrition Recommender Smart Phone App. Details of project are following. This app will: •

  1. guide patients about the choices of food and diet plan according to their health issues.
  2. provide a list of dieting plans

  3. recommend healthy food choices for men, women, toddlers, kids etc. according to their age, weight and health condition

  4. • have the calorie calculator

  5. have some good articles about diet and foods

  6. inform people about the nutrition importance of different vegetables, fruits, beverages, grains, oils, dairy etc.

  7. share some innovative ideas about breakfast, lunch and dinner.

But I don’t know how to design database to implement above functionality. Can someone guide me how many tables should I create and what tables relationship exist?.

  • 1
    It's not quite the sort of question SO is designed to answer; SO is more "you do the design and implementation and we'll help out with any bumps you hit along the way" - there is way too much designing left to do if this is all you've got.. – Caius Jard Oct 12 '19 at 07:26
  • 2
    (Elaboration) ..those aren't "details" of a project; they're a very very basic headline summary of some functions. Do the in depth design of the interface and user stories (how users use the app and what they get out of it) and the data storage requirements will start to emerge. Don't let the data design drive the end result – Caius Jard Oct 12 '19 at 07:28
  • Refer some diet app. Get overview from existing app. Study pros and cons of them. Then create database then design then coding. – Mohsin kazi Oct 12 '19 at 08:53

1 Answers1

0

Introduction

First of all, this is very basic what you wrote us. You should start specifiing those things and get more into details. For example for a diet plan you can think about the properties such plan could have. Properties are e.g. the length of the plan, the nutrition you need and maybe some sport-excercises. Just some samples. Then you may split up the nutrition in one table and so on. Now you can think about if you want to do all the database stuff on your own, or use a framework. Actually the whole database stuff seen in MySQL and so on is done on a webserver, because of security leaks on the client (decompiling, traffic reading, ...). If you want to save data on the local storage or in a local db (SQLite would be you choice) then you should also think about if you want to use an API for that (e.g. RoomAPI by Android Jetpack)

General thing

You should get your self a clear mind which architecture you want to use. You can store data on a webserver and transfer the data via web-interfaces e.g. REST with JSON or XML. You can also store data on the local device in a file or in a database (which is basically also a file with specific interface requirements). You have to decide and consider you require the exchange on multiple devices or just for one device on it's own.

Planning your structures

After you know which architecture you want to use, you can start planning. First of all I would suggest you to get an abstract view of your project. That means just writing down what you want to have and then start writing down the corresponding properties. For a diet-plan this may be the name of the plan, the length, required nutrition and so on... After that you may know, oh okay, I also need a table with the food and you will see (automatically) that there will be a connection. If you see the connection just draw a line connecting those. In an ideal situation you already know the relation of this connection (One to many, Many to one, Many to Many, One to One, see this stackoverflow article: Difference Between One-to-Many, Many-to-One and Many-to-Many?).

Implementing your structures

Anything I do is handcrafted

In the case you want to do all on your own you may use a gui tool for databases to design your database. You can also use commands to do that, what need much more effort. You can decide on your own and on your knowledge.

Pro for gui

  • Easy to use
  • Fast creation of the tables

Contra for gui

  • May use some cryptic names for indexes and keys
  • "May don't let you look behind the scenes"

I rely on APIs

You can also rely on APIs. That means often, that you can program the class according to your plan, then annotate it and the connections/relations would be managed by the api. Such abstraction-layer is Room for Android or Doctrine for PHP, those are just samples and there are much more. Conclusion How you get the data into the database and out of the database is your thing. You could rely on easy use of APIs or get your things done by yourself. It should be a little guide for you to understand database design.

P.S.: If someone has things to edit, do that! I would appreciate that!

Cheers Tarik.

Tarik Weiss
  • 336
  • 2
  • 15