Answer the question
In order to leave comments, you need to log in
How to correctly compose a database to get an array of the following type (more on that later)?
you need to get into the php code, after the request, an array of this kind,
for example
[
'animal' => 'cat',
'body' => ['head' => 1, 'paw' => 4],
'ability' => ['run' => 10, 'jump' => 2]
]
Answer the question
In order to leave comments, you need to log in
Offhand two options.
Option #1, use if the 'body' and 'ability' sets are the same for all animals animal
table, fields: id (int), title (varchar)
animal_body table, fields: id (int), animal_id (int), head (int), paw (int)
animal_ability table, fields: id (int), animal_id (int), run (int), jump (int)
Option #2, use if 'body' and 'ability' sets are different for all animals
table animal, fields: id (int), title (varchar), body (json), ability (json)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question