Nutritics MySQL Test
Nutritics MySQL Test
The attached tables represent foods eaten by clients (users) over a given period. Each food is
tagged to a collector which indicates the meal in which the food was consumed.
Tables Included:
● trackerdata: a log of all foods & quantities eaten for each user at each meal
● trackercollectors: an archive of meals available
● clients: an archive of users available
● allfoods: an archive of foods available
Assessment Questions
Write queries which find the following data. Please write 1 query for each question 1-3. You may
use PHP if necessary:
1. Using the trackerdata table, find the most common 3 foods eaten for each meal, in each
age range: 18-55, 56-65, 66-75, >75 ?
2. Predict which foods will be most likely eaten tomorrow based on the following
parameters. The points below should be used to weight each parameter’s contribution
towards the resultset. Use variables at the top of the query for each parameter. You may
add additional parameters if you wish (for example allfoods.userCount).
a. Meal - 4 points
b. Client’s Gender - 2 points
c. Client’s Age - 2 points
d. Client’s Country - 3 points
e. Day of the week today - 1 points
Sample Input:
SET @meal = 2, @gender = ‘m’, @age = 26, @country = ‘Ireland’, @dayOfWeek = 1;
Sample Output:
...etc
3. Update the query from question #2 to include each client’s personal eating history as an
added parameter. If there is no personal data available, fall back to the generic
parameters. The input variables from #2 should be replaced with a single variable:
clientID.
4. Please give some simple recommendations on how you might optimise this database
schema. Be sure to explain your reasoning (query speed, data robustness, security, etc)
Assessment criteria:
Submission Guidelines
Please submit all responses in a single text or word document with clear labelling, font
formatting and code commenting. If you have points of feedback or recommendations, please
include these inside the document.