Note that there are some explanatory texts on larger screens.

plurals
  1. POPattern to handle "dynamic enums" that a user could modify (programming language agnostic)
    primarykey
    data
    text
    <p>I always face this problem and every time I face this I find a different solution that doesn't satisfact me. This situation doesn't fit a specific language, but involves a database.</p> <p>Imagine that you have a situation, in a management application, where the user (not a programmer so) can fill a table which rapresents the programming skill level of it's employees. Than he can assign those values to emplyees in emplyees table.</p> <p>So the situation in the database is this one:</p> <pre><code>Table: ProgrammingSkillLevel - ID - Name - Value Table: Employees - ID - SomeUselessData - ProgrammingSkillLevelID </code></pre> <p>In a programming fashion I'll usualy do this as an enum (I'll use C#):</p> <pre><code>enum ProgrammingSkillLevel { Starter = 0, Medium, Advanced, } </code></pre> <p>The advantage of this approach is using <strong>Names</strong> instead of values, infact if we change the enum into something like this:</p> <pre><code>enum ProgrammingSkillLevel { Starter = 0, Medium, Good, Advanced, } </code></pre> <p>We won't have any problems because we use names. In my database approach I'm using IDs to avoid some byte wastes (I know there is enum type, but the user should fill the table, not me!), not names, so the advantage is definitely lost.</p> <p>What approach should I use to allow the user to generate what I call "dynamic enums"? Should I use names?</p> <p>I would like to find a good pattern that will apply to all my projects possibly, because I find this situation very often.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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