Store data in JSON in MySQL

0

I have a database in Mysql where, as the project is being developed, the number of fields in some tables has grown exponentially.

The People table, for example, has fields related to personal documents, home address, work address, personal data, academic data, etc.

'empresa' => 
array (size=6)
  'nome' => string 'Empresa Legal' (length=13)
  'funcao' => string '' (length=0)
  'rendimento' => string '' (length=0)
  'endereco' => 
    array (size=7)
      'cep' => string '' (length=0)
      'logradouro' => string '' (length=0)
      'numero' => string '' (length=0)
      'complemento' => string '' (length=0)
      'bairro' => string '' (length=0)
      'cidade' => string '' (length=0)
      'estado' => string '' (length=0)
  'telefone' => 
    array (size=2)
      'fixo' => string '' (length=0)
      'movel' => string '' (length=0)
  'email' => string '' (length=0)

I had thought about grouping the data in Json and storing each group in a specific field but I'm not sure if this is a good practice or if it affects database performance.

My question is essentially about good practices regarding data storage, as I can handle JSON if it gets into trouble.

If this is not the best way, I accept suggestions for structuring this data.

    
asked by anonymous 14.08.2017 / 04:53

1 answer

1

Hello,

In this case, you would be running away from the first normal way. Database normalization is essential to ensure integrity and performance.

So this would not be recommended in this case you are using MySQL. But for this type of situation there are NoSQL databases, which behave exactly this way, storing collections (as if it were JSON) that do not need to follow a schema plastered.

To read more about Database Normalization: Data Normalization

To read more about NoSQL: NoSQL MongoDB

    
15.08.2017 / 19:16