考虑两个表:“用户”和“计算”。
Calculation's structure: {“id”: <primary_key>, “array”: <array of numbers>, “calculations”: <array of all calculations for given array of numbers>}
用户创建这些计算。
我希望能够查询与特定用户关联的计算。据我所知,我需要用户参考计算模型才能做到这一点。
问题是:是否可以通过在计算模型上提供用户参考来避免更改计算结构?
我正在考虑在用户模型上有一个带有计算ID的数组字段。这是可行的解决方案吗?
You can use ArrayField. You should create this field in your User model and you can fill it with IDs of Calculations. It would propably looks like this:
当然,您可以更改空白选项,我写它只是为了说明如何在两个字段中都可以使用它。