#Best approach to handle dynamic data

7 messages · Page 1 of 1 (latest)

crimson garnet
#

Hello Django Devs,
I have a list of licensing's that any user can have. The License is connected with their account. I am just trying to think the best way to store the data. Should I just create a new colum that is a Boolean value for weather or not they have the license or should I create a table that will relate license type to user and have a lookup table for all the license types. I am leaning more towards the lookup table of license types and then the relational table so that when I am displaying the choices to the user, It just reads from the license lookup table.

languid shadow
crimson garnet
#

Okay So I have my main users table, then a lookup table containing the license types, then a relational table that connects users to license, does this sound right?

languid shadow
#

Yes. A ManyToManyField field creates that table automatically. But you can specify a through model to add extra fields to a relationship

crimson garnet
#

Okay cool! I didnt realize that a manytomany created that table automatically

crimson garnet
#

One thing I just realized. How would I store the license data for the user. This license data is getting verified, so I need to store the uinique license ID per user. How would I best do that

languid shadow
#

Use a through table and add that per user license ID to that table.