In this homework, we will create the basis for a shopping list as it should really be -- not as all lame shopping lists are implemented!
We will not worry in this homework about actually making the predictions: we will simply make sure that we store enough information to make predictions possible. In particular, we want to remember which items have been listed together, so that in the future (not in this homework!), we have the data to analyze correlations.
You should store all shopping lists that have been entered in the app (let’s worry later about what to do if the storage grows too large; let us hope that memory capacity in phones will increase faster than our gluttony). For each shopping list, we should store at least the following information:
An item is not a string. It is an “entity”, that is, something with its own database row, to which we can associate information. In practice, you will need an Items table, where you store the item name, and you should create a many-to-many relation between the items, and the shopping lists in which they were entered. In this way, one can search the item for “mozzarella”, and then see all the shopping lists in which mozzarella was ever ordered, or count how many times in the last month you bought mozzarella, etc etc.
In this Items table, you should store:
The item rank and last ordering date will be used to implement suggestions, but again, let’s not worry about it now. You can just leave the rank to 0, or increment it each time an items is ordered, as you like.
So, you need to build an app with the following:
Data should be stored as detailed above, and the app should save its state.