title: XML Schema totalDigits/fractionDigits vs. SQL precision/scale
body: <p>I'd like to find out the correspondence between XML Schema <code>totalDigits</code>/<code>fractionDigits</code> and SQL numeric precision/scale.</p>
  
  <p>1) Assume we have the following simple type:</p>
  
  <pre><code>&lt;xs:simpleType name="DecimalNumber"&gt;
      &lt;xs:restriction base="xs:decimal"&gt;
          &lt;xs:fractionDigits value="17"/&gt;
          &lt;xs:totalDigits value="18"/&gt;
      &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  </code></pre>
  
  <p>How would I represent it in SQL? Let's assume HSQL dialect (it does not matter much). I'm interested in the most restrictive SQL type which could hold all the values from the value space of the XML Schema simple type.</p>
  
  <p>Would it be <code>numeric(18,17)</code>? Or <code>numeric(35,17)</code>?</p>
  
  <p>2) What if we have just <code>totalDigits</code>?</p>
  
  <pre><code>&lt;xs:simpleType name="DecimalNumber"&gt;
      &lt;xs:restriction base="xs:decimal"&gt;
          &lt;xs:totalDigits value="18"/&gt;
      &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  </code></pre>
  
  <p>What would be an adequate representation in SQL?</p>
  
  <p>3) Or just <code>fractionDigits</code>?</p>
  
  <pre><code>&lt;xs:simpleType name="DecimalNumber"&gt;
      &lt;xs:restriction base="xs:decimal"&gt;
          &lt;xs:fractionDigits value="17"/&gt;
      &lt;/xs:restriction&gt;
  &lt;/xs:simpleType&gt;
  </code></pre>