
Simulating Sales Data and Working with Databases
The Food Factory example is about a fictitious company called The Food Factory. They sell custom meals for people looking for healthy food. They allow their customers to choose the macronutrients combinations they want, as well as their protein sources. Macronutrients are the base for any diet, and they are composed of carbohydrates, proteins, and fats. Customers can choose the percentage of each macronutrient, as well as their protein source (fish, chicken, beef, or vegetarian); then, The Food Factory will come up with a tasty meal which fulfills their diet specifications. They have found some great combinations this way, and if they continue to do as well as they have, they will add more meal options, as well as fixed recipes, according to what their customers like most.
The Food Factory has done a good job so far and they have a system in place that allows them to collect a good amount of data across their five store locations, as well as keep track of customer messages. Our job in this example will be to analyze the data to diagnose the current state of the business and propose ways to improve it. To do so, we will use lots of visualizations in Chapter 5, Communicating Sales with Visualizations; perform text analysis on customer reviews in Chapter 6, Understanding Reviews with Text Analysis; and provide automatic diagnosis of the current state of the business in Chapter 7, Developing Automatic Presentations. Sounds good, right? However, before we can do all of that, we need to get a hold of the data, and we don't have it yet. We're going to simulate it! This chapter will show you how to design a non-trivial data simulation to produce the data for the example. Furthermore, The Food Factory, as well as many organizations, doesn't always make our lives easier by providing CSV files, and they often have databases we need to work with. This chapter will also show you how to work with such databases.
Some of the important topics covered in this chapter are:
- Designing and implementing non-trivial simulations
- Simulating numbers, categories, strings, and dates
- Function signatures with parameter objects
- Reusing functions in different contexts
- Mixing internal and external data
- Working with relational databases