M
M
Mamol272017-10-30 12:40:57
MySQL
Mamol27, 2017-10-30 12:40:57

How to design a database with a variable number of parameters?

For a long time I didn’t deal with the database, and I only knew the basics, now there is a need to design with an unknown number of parameters, and with the possible further addition of these parameters.
As far as there was enough residual knowledge, I did, but I'm not sure, an expert assessment is needed, and if done incorrectly, a kick in the right direction.
the table shows the expectation from this database.
59f6f38c0c465834872649.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DENIS SHELESTOV, 2017-10-30
@djdeniro

There are two ways:

  • Create another table with the fields: id , person_id , name , value , where person_id is the id from the person table, name is the name of the parameter, value is the value
  • ,

    C
    cicatrix, 2017-10-30
    @cicatrix

    On some RDBMS, the light did not converge like a wedge. Look in the direction of nosql, it seems to me that it will suit you more.

    D
    Dmitry, 2017-11-09
    @DimonSmart

    I recommend looking towards EAV. But!!! Watch very carefully. There is a very large pile of goodies and about the same bunch .... hmm .... not goodies. Choose only for you.
    And I'll add here a link to a very similar discussion:
    How to store abstract data models in relational databases?
    By the way, try to honor your question. Perhaps, if there are few of these most unknown parameters, then the best way would be to simply expand the plates.
    In the direction of EAV, you need to look if you have a quantity and the parameters themselves can differ greatly from object to object. And these parameters themselves can appear spontaneously at the request of your users.
    I also highly recommend considering a compromise option in which you will use the classic structure of fields and tables. And somewhere near it, an EAV structure will be attached to it for experiments with fields. In this case, the main load will be on classical structures, and all experiments with additional fields will be essentially separate.
    If any of the experimental additional fields later becomes very necessary and everything necessary, then no one bothers to refactor the database structure and transfer this field to the main tables....

    Didn't find what you were looking for?

    Ask your question

    Ask a Question

    731 491 924 answers to any question