T
T
Timofey Bulgarian2019-06-19 10:33:27
Django
Timofey Bulgarian, 2019-06-19 10:33:27

How to implement a model of many types in one?

Let's say we have a User table. It has generic fields for the user. But users can be n different types. But only 1 of them. Each type includes custom fields set for that type. What is the best way to organize this model?
Example. Any user has fields: id, name, email, type. But depending on the type, it may have an additional set of parameters. If the user is of type simple, then he also has field1 and field2, and if he is of type business, then field3 and field4. That is, the set of additional fields for each type is different.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan Ruslanov, 2019-06-19
@dasauser

add users.type field.
reformulate the question.

D
Denis Derepko, 2019-06-19
@uDenX

single table inheritance

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question