title: User Defined Fields storage in Postgresql
body: <p>I'm looking at building a system which will include user created fields which will use Postgresql as the database. I've read that the EAV model for this isn't great and that a jsonb column to store the custom fields will be the best route.</p>
  <p>I want the user to be able to build their own queries to the data as well so is the best way to go to store the custom field names in a table and store the actual data in the jsonb column, that way when it comes to building the queries the webapp can query the custom fields table for a reference as to what fields are available and their types?</p>
  <p>Tickets</p>
  <ul>
  <li>ID</li>
  <li>WhenCreated</li>
  <li>LastUpdated</li>
  <li>CustomProperties {JSON B column, key value pairs where the key names will be stored in the custom fields table}</li>
  </ul>
  <p>Customfields</p>
  <ul>
  <li>ID</li>
  <li>FieldName</li>
  <li>WhenCreated</li>
  <li>FieldTypeID</li>
  </ul>
  <p>FieldTypes</p>
  <ul>
  <li>ID</li>
  <li>FieldTypeName {String, Date, etc}</li>
  </ul>