[Answered ]-How to add extra columns for a model if in particular category in Django + Postgres

1๐Ÿ‘

  1. Add nullable fields first.
  2. Wait for A. need to add more and more nullable columns and B. building more and more queries using these nullable fields.
  3. Based on gathered evidence of data and use cases, evaluate what is best, whether keeping them as nullable columns or adding a JSON field.

Two categories for making the desition come in form what is best for you and for the app:

Evaluating what is best for you is to define what is easy to read and understand to other developers; usually, the solution with less code and easier to document is likely better all the time.

To evaluate what is best for the app is to define what is heavy for Django or postgres to handle, nowadays postgres handles very well JSON fields and Django supports them as if they were important for the ORM. Still, once again, you have to throw consistent schemas for it to be efficient.

๐Ÿ‘คpanchicore

0๐Ÿ‘

You can use mongoDb for schemaless database structure. You can create different "columns" for different "rows" with it.

๐Ÿ‘คTech

Leave a comment