Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Storing many key-values pair correctly?

I have some settings files, that will differ in naming of the different settings.

setting1 : true
setting2 : false
setting3 : false

settingsss1 : true
settingsss2 : true
settingsss3 : true

the naming is user generated so cant really make columns for them.

i though doing something like making a table with

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Id - Key - Value

This would then give 50 entries for a settings file with 50 settings.
Would it be better to just save these as JSON string in a field in the DB as MediumText?

i expect to have around 100 new saves of these every day. giving 100 x 50 x 365 = 1.800.000 entries a year..

The thing is I need to be able to look thru these in a decent way, to compare their settings.

should I go with JSON string or entry pr. parameter. or even a 3rd option?

>Solution :

For simple, flat key/value pairs with simple values, use a normal table. If the values are just true/false use boolean for the value column to save a little space.

If the values can be a mix of types (dates, numbers, strings, lists, nested key/value pairs) use the JSON type. It can be indexed and searched.

Millions of entries a year is not a lot if they are properly indexed. Handling large amounts of data is what SQL databases are good at.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading