1 of 35
DATABASE
MANAGEMENT
SYSTEM
PROJECT REPORT
FIT.IO
A better Health and Fitness platform
that integrates into your daily life and
rewards a healthy lifestyle
by Team Butter Naan (Group 53):
Udhvarg Chaturvedi | 2018112
Hamzah Akhtar | 2018051
Archit Agrawal | 2018221
Shaney Waris | 2018308
Gavish Gupta | 2018390
2 of 35
Abstract
The health and fitness industry is one of great
importance in our lives, and promoting a healthy lifestyle
is essential in current times where unhealthy foods are
so glorified and popularised in the world. We aimed to
make a platform that integrates and keeps record of
your daily lifestyle habits and motivates you to be more
active and healthy.
With the combination of a well-designed RDBMS, a user
friendly interface, and advanced ML techniques, the
platform is able to assist users in their daily lives by
motivating them to achieve their daily fitness goals,
recommending healthy dishes for meals, along with the
option of ordering from nearby healthy restaurants. The
user can also share their details with trusted medical
centres and doctors through the app for better medical
assessments when the user requires it. Moreover, the
user will also be provided with verified dieticians to
connect with and hire to look over their lifestyle habits
and advise them accordingly.
3 of 35
Week 1
Ideation and finalisation of
the application, and
identifying stakeholders
Work Division:
All work was done together
and everyone contributed
equally.
4 of 35
Project Description
A platform which constantly keeps track of user calorie
intake and appropriately suggests various meals, while
incentivising a healthy lifestyle by providing coupon discounts for
various fitness products and by various insurance companies.
1. Keeping track of the user’s daily calorie intake
2. Keeping track of the user's daily physical activity and
workouts using your mobile sensors, or by synchronising with
your fitness band/smartwatch.
3. Suggest food recommendations based on the user’s daily
calorie intake
4. Suggest workout regimens based on daily user physical
activity
5. Link user account, and share daily lifestyle statistics with your
dietician’s account to directly receive feedback about your
current calorie intake, and suggestions regarding your
workout regimen.
6. Link daily activities and intake trends to medical record
7. Closely monitor at-risk patients and direct feedback their data
to a hospital approved by the user, where the hospital will
deploy emergency services in case of unprecedented
irregularities.
A very well designed database management system would be
required to deploy a web app of the scope aforementioned.
5 of 35
Stakeholders for the Platform
• Users
• Hospitals
• Restaurants
• Healthcare Industry
1. Dieticians
2. Product Manufacturers
• Insurance Companies
6 of 35
Week 2
Roles of each stakeholder
and the purposes fulfilled
by using the DB
Work Division:
All work was done together
and everyone contributed
equally.
7 of 35
Stakeholder Roles
Users
• To keep a detailed track of health and fitness, along with food
intake and burnt calories.
• Get food recommended based on their daily regimen
• Suggestions for workout
• Recommend Restaurants based on location
• Targeted Users
1. Fitness Buffs and Calorie Conscious Users
2. Patients whose ailments require constant monitoring of
food intake
Hospitals
• Maintain Updated Records
• Access user data only when visiting the doctor.
• Patients get more attention from this system.
• Red Alert Users
1. Constant updating and monitoring of data.
2. Revert to normal users when out of risk
Healthcare Industry
• Dieticians
1. Dietician Account.
2. Approved Dieticians regularly keep track of client
schedules
3. Easily Recommend suggestions
4. Active role in client’s lives.
8 of 35
• Product Manufacturers
1. Provide free advertising for their products
2. Get discount codes for products to supply to users.
Insurance
• Analyze and predict whether the person is profitable or not.
• Advertise insurance to users.
• Users can recommend an insurance company to other users
too.
Restaurants
• Food suggestions
• More demands for healthy restaurants
1. Become a motivation for other restaurants to prepare
healthy food.
• Become a popular choice amongst our users
• Suggest restaurants to add certain types of foods popular
amongst users
• Generate better sales
User:
1: How many calories have I burnt today?
2: What foods can I eat which are healthy for me based on the
calories?
3: How many customers satisfactorily left the dietician (above 3
star)?
9 of 35
4: What is the average fee for dieticians available?
5: What all restaurants are most popular for breakfast?
Hospitals:
1: How many users have verified us as their hospitals?
2: How many users under us are at-risk?
3: What is a user n’s daily exercise regime?
4: How many hospitals have a higher rating than hospital - n?
5: How many users live nearby?
Product Manufacturers:
1: How many coupons are we providing?
2: How many coupons have been distributed amongst users?
3: What is the most popular coupon distributed?
4: Which user has the maximum number no of our coupons?
5: What is the average number of coupons a user has?
10 of 35
Restaurants:
1: How much money is made from orders placed after midnight
before closing time?
2: How many users have ordered more than once from us?
3: What is our most popular item?
4: How much money have we made the past year?
5: What is the average revenue generated per day?
Insurance Companies:
1: How many users are insured by us?
2: How insurance companies can generate better sales?
3: Potential users to be insured?
4: How many users have more than one insurance?
5: How many potential users have been serviced by us?
11 of 35
Week 3
Designing the Database
Schema
Work Division:
All work was done together
and everyone contributed
equally.
Note: The following schema is only a tentative schema which can be revised and
updated in following weeks
12 of 35
DATABASE SCHEMA
USER DB
users -
User_ID int
NotNull
Name varchar(30)
NotNull
Age int
NotNull
at_risk bit
Dietician_ID int
No_of_steps int
Current_calorie int
Health_History MEDIUMTEXT
Avg_Calorie_Intake int
Diseases TEXT
Location TEXT
NotNull
Primary Key - User_ID
Foreign Key - Dietician_ID
daily_record_n
Here n is the uid of a user.(EG daily_record_5 is the daily
record of user with UID 5)
13 of 35
date int
NotNull
steps int
cal_intake int
avg_heart_rate float
sleep int
Primary Key - date
at_risk-
U_ID int
NotNull
disease Varchar
NotNull
at_risk TINYINT
NotNull
Primary Key - U_ID
Foreign Key - U_ID
HOSPITAL -
Name varchar(40)
NotNull
Location TEXT
at_risk bit
14 of 35
Specialities TEXT
Hospital_ID int
NotNull
Primary Key - Hospital_ID
Foreign Key - NONE
RESTAURANTS-
Name varchar(30)
NotNull
Location TEXT
Rating int
Cuisines varchar(40)
NotNull
Restaurant_ID int
NotNull
Menu MEDIUMTEXT
Primary Key - Restaurant_ID
Foreign Key - NONE
PRODUCT MANUFACTURERS-
Product_ID int
NotNull
Name varchar(30)
NotNull
15 of 35
typeofProduct varchar(70)
NotNull
Coupons int
NotNull
Primary Key - Product_ID
Foreign Key - NONE
DIETICIANS-
Dietician_ID int
NotNull
Name varchar(30)
NotNull
Qualification TEXT
Rating int
NotNull
Primary Key - Dietician_ID
Foreign Key - NONE
HEALTH INSURANCE-
Insurance_ID int
NotNull
Name varchar(30)
NotNull
Clients MEDIUMTEXT
Possible_Clients MEDIUMTEXT
Primary Key - Insurance_ID
16 of 35
Foreign Key - NONE
COUPONS-
Coupon_ID int
NotNull
Valid_date date
NotNull
Type varchar(70)
NotNull
Details varchar(30)
Product_ID int
NotNull
Primary Key - Coupon_ID
Foreign Key - Product_ID
FOOD-
Name varchar(30)
NotNull
Calorie int
NotNull
Cuisine varchar(20)
NotNull
Recipe varchar(100)
Primary Key - Name
Foreign Key - NONE
MANAGES (User-Dietician)
17 of 35
User_ID int
NotNull
Dietician_ID int
NotNull
Primary Key - User_ID
Foreign Key - Dietician_ID
18 of 35
Week 4&5
Populating tables with
data
Work Division:
Udhvarg: Populating Coupons and product_manufacturers,
Document updation
Archit: Populating User and daily_record_n
Hamzah: Populating Restaurants and Menu
Shaney: Populating Dieticians and Health_Insurance
Gavish: Populating Hospital and food
19 of 35
All the tables have been populated with at least 50 entries for now.
The data has been collected manually where required, and
generated and updated using scripts where deemed appropriate. A
few examples of populated tables are given below:
20 of 35
Week 6
Creating Indexes and
Forming Queries
Work Division:
Udhvarg: Creating Indexes,
Document Updation
Gavish: Forming Queries
21 of 35
Indexes
• CREATE UNIQUE INDEX `user_index_0` ON `user` (`id`);
• CREATE INDEX `exer_entry` ON `userexercise` (`uid`,
`datetime_e`);
• CREATE INDEX `nutri_entry` ON `usernutrition` (`uid`,
`datetime_c`);
• CREATE UNIQUE INDEX `restaurants_index_3` ON `restaurants`
(`id`);
• CREATE INDEX `order_entry` ON `userorder` (`uid`, `datetime_c`);
• CREATE UNIQUE INDEX `userorder_index_5` ON `userorder`
(`oid`);
• CREATE UNIQUE INDEX `coupons_index_6` ON `coupons`
(`code`);
• CREATE UNIQUE INDEX `productmanufacturers_index_7` ON
`productmanufacturers` (`id`);
• CREATE UNIQUE INDEX `dietician_index_8` ON `dietician` (`id`);
• CREATE UNIQUE INDEX `hospitals_index_9` ON `hospitals` (`id`);
• CREATE UNIQUE INDEX `food_index_10` ON `food` (`id`);
22 of 35
Queries
1: How much money is made from orders placed after midnight before
closing time on 26th april?
Select SUM(price) from user order where datetime_c BETWEEN
'2020-04-25 11:59:01' AND '2020-04-26 02:00:00’ ;
2020 userorder
2: How many users have ordered more than once from us?
select count(counttable.uid) as multiple_orders from (select
uid,count(uid) as u from userorder group by uid) as counttable where
counttable.u>1;
3: How many coupons is company with id 12 providing?
Select count(*) from coupons where cid = 12;
23 of 35
4: What all restaurants are most popular for breakfast?
Select distinct r.name from restaurants as r, usernutrition as u , userorder as o where
u.uid = o.uid and o.rid = r.id and u.foodtype = 0;
5: How many users have verified us as their hospitals
select count(*) from trustedhospitals;
6: How many users under us are at-risk
select count(*) from at_risk_users;
FCount(*)(at_risk_users)
7: Which is the most popular dietician having the highest rating?
Select MAX(no_of_reviews),rating from Dietician Order By no_of_reviews DESC, rating
DESC;
24 of 35
8:What is the average cost for a meal preferably breakfast?
Select Avg(p.price) from usernutrition as u, userorder as p where u.uid = p.uid and
u.foodtype =0;
9: Which is the best dietician available below the average price?
Select * from dietician where rating in (select Max(rating) from dietician where price >
(select AVG(price) from dietician));
10: what is the average calorie intake for all the users in breakfast dinner and lunch.
Select foodtype,count(*) from usernutrition group by foodtype;
25 of 35
Week 7
Embedded SQL Queries
Work Division:
Hamzah, Archit : Embedded SQL Queries
Udhvarg: Document Updation
26 of 35
1) Updating user data from edit-profile tab
2) Extracting food data
3) Dietician data extraction
27 of 35
4) Get user’s hired dieticians
5) Updating dietician data
6) Hospital data fetching
28 of 35
7)Validate login attempt
8)Get dishes that user likes
29 of 35
Week 8
ER Model
Work Division:
Udhvarg: Normalisation, ER Model and
Diagram w. Revisions, Document Updation,
Refactoring population scripts and populating
according to the new schema.
Archit, Hamzah, Shaney, Gavish: Refactoring
population scripts and populating according to
the new schema.
30 of 35
As we progressed with the development of our
platform, we realised that the previous schema
needed to be updated with additional tables, and
normalised as well. The following is the updated
ER diagram post-normalisation.
31 of 35
Week 9-12
Web App Development
Work Division:
Archit : Back-end, Collaborative Filter and
Platform Deployment
Hamzah: Back-End, Linking Back-end and
Front-end
Shaney: Front-end of the Platform
Udhvarg: Team Management and Document
Updation
32 of 35
Bonus/Innovative Feature:
Fully Deployed Web-App built from scratch, implementing
features like:
1) Easy to use interface to access data.
2) Implemented collaborative filters (Machine Learning) for
getting personalised meal recommendations.
3) Hosted web-app provides easy user-accessibility on all
devices.
4) User data provided to trusted hospitals for monitoring
at-risk patients.
5) Incentivising a healthy lifestyle by providing coupons
upon certain milestones.
6) Ordering food from verified healthy restaurants through
our platform.
Technologies used to deploy the Web-App
Front-End : HTML, CSS, JS, Bootstrap 4, JQuery
Back-End : Flask, JS, Ajax Calls, MySQL Connector
33 of 35
34 of 35
35 of 35
Find the hosted web-app over at: https://
butternaan.herokuapp.com/login
Find the related resources over at https://github.com/
nahimilega/Butter_Naan