For example, there is a table Car . Fields - id , type , name . Type can be many different. And for each Car by type may be additional data. And may not be.
Suppose there is a type big . For it you need to specify another year . And for type light specify shop and address . It turns out that Car must be in the same table, and all have id , type and name . But in certain situations, they should also have additional. data.
Option 1 - add all required columns to the Car table. It turns out, if we consider our example - id , type , name , year , shop , address . But for type big the shop and address fields are always empty. And for type light year will always be empty. And if for each type there will be ~ 10 - 100 add. fields, records with ~ 100 fields will be obtained, ~ 90 of which are empty.
Option 2 - the main info is stored in Car . For more create CarBig , and CarLight . But in this case you cannot select all the necessary data at once with one request, since Initially, you do not know which table to merge with.
Option 3 - design as in option 2. For requests to do a left join for all additional tables. But if we assume there is a type middle , which doesn’t need a separate table at all, then in such a case we will have to create a table as well. CarMiddle . And it will always be empty. And if we have type middle1...100 , then for all we will have to create tables. Well, to unite with all, respectively, too.
Those. the idea is that there is general data and there are additional data that exist only for certain records. And the question is how best to organize it all. Are there any other options? And if not, which one is the most acceptable?
typefield, it can be seen initially from which table to merge. Option 3. No need to create an additional table where it is not needed. - Sergey