Designing Data Models: Customers Additions
Here are some more bits of data that you might want to store separately:
- When the customer logged in
- When and how much did the customer order - maybe get it from orders
The information from the above models can be stored alongside the customers data model in the form of totals. These can be useful if you need to display this information to a web app or mobile device and do not wish to calculate it per visit. What would be needed though, is for these to be calculated on set intervals (such as once per day or once per hour).
Let us see some examples of these:
- Last time a customer logged in?
- Has the customer been active this month?
- What is the total lifetime spend of the customer?
- How much money does the customer have left outstanding with the company?
Some more information that we can store within the customers data model are things like conditionals. These typically are named is_ something, such as isActive. These can be a boolean datatype or an enum with a specific set of options. The advantage of using these are that they:
- Add more information - instead of just data - to the customer
- Reuse applied business logic by other parts of the application or entirely different applications in other programming languages.
- Could potentially save time calculating the results of these on the fly (similar to totals).
Some examples could be:
- status (active, closed, suspended, new)
- customer_matrix (bottom20, top20_, _middle60)