Tuesday 26 February 2019

What is the best way to keep track on tables or some data for analytics?

For an instance, take django model classes as below.

So, now the question is that how can I efficiently implement analytics for generating number of product sales per day, number of sales per month, number of profit by day and so on ?

One Possible solution is on every sales update counts of that particular day. But if I have very large customer base (i.e 1M customer and 500 sales per hour).

So is there any better way to achieve this?

These schemas are just for reference only

class Product(models.Model):
    name = models.CharField(max_length=20)
    category = models.ManyToManyField("Category", null=True)
    ...
    ...


class Sales(models.Model):
    product = models.ForeignKey("Product")
    price = models.DecimalField(max_digits=20)
    timestamp = models.DateTimeField()
    ...
    ...




from What is the best way to keep track on tables or some data for analytics?

No comments:

Post a Comment