我正在开发一个手机应用程序,它在每次打开应用程序时都会将用户的位置发送到后端。
,我的目标是为用户存储尽可能多的位置数据,这样我就可以做一些机器学习来计算他们日常活动区域中的哪些职位将最适合他们。
我使用GeoDjango和PostGis来使应用程序位置感知,并且很难确定数据库中哪种数据结构最适合这种情况。
问题在于我是否应该给每个用户一个location = pg_fields.ArrayField()属性,这个属性最终会变得非常大,还是使用location=models.ManyToManyField(UserLocation)。我知道,在具有大数组的Postgres中,吐司表是一个问题,但在运行机器学习算法时,当试图为用户提取数据时,这是否是一个不值得强调的大问题?
发布于 2018-03-14 22:30:37
将您的位置数据保存在它自己的模型中:
class UserLocation(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, ...)
recorded_at = models.DateTimeField() # time recoreded on phone
created_at = models.DateTimeField(auto_now_add=True) # time saved on db
location = models.PointField()
accuracy = models.IntegerField() # meters, rounded up
altitude = models.IntegerField(null=True, blank=True) # meters, rounded
# more info... IP, phone type, phone id, session id, app version etc.https://stackoverflow.com/questions/49246721
复制相似问题