title: Database: Storing Taxes Rates & Information
body: <p>Let's imagine:
  there's a website, a kind of job board. Products are virtual there. There are extra options and fees for posting an entry.</p>
  
  <p>Now, in our country, there's VAT, really complicated rules. Business is located in PL:<br>
  - users from PL - VAT rate is 23%<br>
  - individual users from EU - VAT rate is 23%<br>
  - companies from EU - NP (not apply)<br>
  - companies/individual users outside EU - NP (not apply).  </p>
  
  <p>Now I'm wondering about the best approach with database design. We have following tables:</p>
  
  <pre><code>countries
  code VARCHAR(3) PK AI
  NAME VARCHAR(200) NN
  
  users
  country VARCHAR(3) FK_countries_code
  account_type TINYINT //0 - individual, 1 - company
  </code></pre>
  
  <p>When applying tax rules few things apply:<br>
  - user location<br>
  - user account type.</p>
  
  <p>Do you have any suggestions for database design? I was thinking about altering countries table and applying some denormalization here - creating few columns: <code>vat_rate_eu_personal</code>, etc. but this is terrible idea. I was also hinking about implementing new tables: <code>tax_rates</code> and <code>tax_rates_rules</code> when the information will be stored. However have no idea about structure of the second table.</p>
  
  <p><strong>Edit</strong><br>
  To make it clear: there's no 0% rule for me, it's called NP (not apply). However, the tax rules have one major requirement: company from EU need to provide valid VAT ID. That's why we created two account types: for company accounts and individual users.</p>