Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I try to not keep data in any string based formats. But I encountered several situations, in which it was not possible to know in advance how the structure of the data will be (e.g. it was possible for the customer/end-user to dynamically add fields).</p> <p>In contrast to your approach, we decided to store the data in XML, e.g. in your case this would be something similar like this:</p> <pre><code>&lt;user id="1234"&gt; &lt;name&gt;Gina&lt;/name&gt; &lt;postion&gt;HouseMatriarch&lt;/position&gt; &lt;/user&gt; </code></pre> <p>This gives you the following advantages:</p> <ul> <li>The classes to work with the data (read/write) are already available in the framework (e.g. XmlDocument or XML serialization)</li> <li>you can easily exchange the data with other systems (if/when required)</li> <li>You can store the data in a file</li> <li>you can store the data in a database column (xml data type). You can even query that column when using SQL Server (although I'd try to avoid storing data in XML, that has to be queried)</li> <li>using XML allows to add additional fields to your data at any time</li> </ul> <p><strong>Update</strong>: I'm not sure why my answer was downvoted that much - maybe it is because of the bad example. Therefore I'd like to make it clear: I would not use XML for properties such as an ID/primary key of a user, or for standard properties like "name", "email", etc. But for "extended/dynamic" properties (as described above) I still think this is an easy and elegant solution.</p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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