Create Mysql Database Table

Asked

Viewed 81 times

1

I have the following table in CSS:

inserir a descrição da imagem aqui

I need to create the tables of the Mysql database, however, I’m not sure how to work this... It will be just "Updated" all the information in the table... What worries me is the percentage ranges... How could I develop this? I make a table for each? Ex: parametros_inss (idParametroInss, range, starting value, Final value, percentage) being inserted: (1, 1, 0,00, 1,000,00, 8%)...

Does anyone here have any suggestions?

  • Good afternoon André, I recommend making more intuitive titles. Read: http://answall.com/help/quality-standards-error

  • Okay! Thank you William

1 answer

2


Well, if as far as I understand you’re having trouble with the modeling.

As far as I have identified you will work with many records, with many parents and many children, taking away the possibility of a 1:n relationship.

I don’t know if many will agree, but I would at first make a table of values storages, where at each value I would define a key and a category for it, at the value I would play the values of this category and track as json_encode

For example:

inserir a descrição da imagem aqui

I would query:

SELECT * FROM storages where `category` = 'faixa_inss' and `key` = '1_faixa'

This query would return me all category values faixa_inss and that they are 1_faixa.

In the JSONi have an array with the values, which you can work with them.

So you could do several records of storages. When you want to change just recover the array by json, manipulate and save again as json.

So, in my opinion, your bank will be more readable and performative.

Behold bank structure in SQLFIDDLE

  • It is an interesting option, it is worth mentioning that I will have to add idEmpresa, and idProfissao, each company, may have its list of professions, which in turn, may have these parameters mentioned... I believe that only by changing its structure, would it be valid, what do you say? Thank you for the idea.

  • Just put in the table storages respective fields, because each company and profession will have their Torage. It will be id | idEmpresa | idProfissao | category | key | value

  • Exactly, and to add the way you created it, Torage: would then use serialize()?

  • serialize($this['date']);

  • @Andrébaill yes. To decide to use serialize or json_encode I recommend to read: http://stackoverflow.com/questions/804045/preferred-method-to-store-php-arrays-json-encode-vsserialize

  • 2

    Don’t forget to mark the answer as correct, @Andrébaill

  • In fact, I already use serialize for system permissions, so I could work more easily...

  • .I can’t answer your chat, tell me I’m not logged in

  • Just one question: The ones that are 3 or 4 tracks... I would use how? the name of the fields? I’m half lost yet.

  • Andre, is a table of Storage. You will insert in the table the Storage for this track category = faixa_inss and key = 2_faixa and etc... Each log a new record.

  • 1

    @Andrébaill see example: http://sqlfiddle.com/#! 9/eaf22/1

  • So, in this case, that’s just it... however, I’m going to need these parameters at another time, as I will do the research if such a parameter exists... I think it would complicate more, what do you think?

Show 8 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.