Note that there are some explanatory texts on larger screens.

plurals
  1. POFixed Data storage/referencing practices
    text
    copied!<p>I've been trying to work out the best practices on storing non-volatile values.</p> <p>A common solution is to store it in a database, for example if you are storing types of something, you then have a structure for normalization.</p> <p>However, my problem is that this data will hardly ever change, and even if it does, the occasion will be so rare that it would prove more efficient to hard code it (a class of constants for example).</p> <p>The second problem is that there is a risk (if small) that the data will be deleted, and finally, every installation would require this data be created first.</p> <p>I am trying to build a system that does not depend on data to at least function (not break), I do feel that data should be dependent on code to give it meaning, opposed to code being dependent on data to function.</p> <p>Has anyone found an elegant methodology to this?</p> <p>I have tagged as PHP, Symfony and Doctrine because these are the tools I am working with, the question is generally application/framework agnostic, but if you can give examples based on those tools it would be helpful.</p> <p>Edit:</p> <p>An example off the top of my head could be storing product types in a database. I don't mean categories of products, much lower level. Is the product material (something you can touch), a service, information, or digital media.</p> <p>Out of the physically possible variants that I can think of, only these four exist. It feels meaningless to create a table for these types, but it also feels inelegant to hold a field in the products table stating which it is.</p> <p>Based on which one it is, four very different branches of functions are possible, and these functions would be hard coded (with some level of scalability obviously).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload