title: Better Database design for hibernatre?
body: <p>I am new to database design. I am using MySQL</p>
  
  <p>I have a <strong>Form</strong> table which contains a field <strong>Country</strong> </p>
  
  <p>Since the values in this columns can be one from the country list only, so I made this column <strong>int</strong> instead of <strong>varchar</strong> and put the list in a new table. shown as below:</p>
  
  <ol>
  <li>Instead of having country column like</li>
  </ol>
  
  <p><code>country varchar(255) NOT NULL</code></p>
  
  <ol start="2">
  <li>I made it countryCode with datatype INT and added a Foreign Key to table <strong>CountryMaster</strong> which is shown as below</li>
  </ol>
  
  <p><code>...
  countryCode INT NOT NULL,
  FOREIGN KEY (countryCode) REFERENCES CountryMaster (countryCode),
  ...</code></p>
  
  <p><code>create table CountryMaster(
      countryCode INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
      name VARCHAR(255)
  );</code></p>
  
  <p>It is working fine, but the issue is that the same table contains many more column like <strong>formStatus</strong> (with possible values Draft, Saved, Approved), <strong>gender</strong> (Male, Female), <strong>bloodGroup</strong> (A, B, O), <strong>rHFactor</strong> (+ve, -ve), <strong>occupation</strong> (Service, Business, Student, Unemployed) etc. If I will make separate table for each such column I will end up in 20 to 25 Master tables.</p>
  
  <p>I also tried to put all such Master Date in a single table i.e. <strong>CommonMaster</strong> with columns <strong>type, key and value</strong> shown as below:</p>
  
  <p><code>create table CommonMaster(
      commonCode INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
      type VARCHAR(255) NOT NULL,
      key  INT NOT NULL,
      value VARCHAR(255) NOT NULL
  );</code></p>
  
  <p>with values like:</p>
  
  <pre><code>   code type       key value
       7  BLOOD_GROUP 1   A
       8  BLOOD_GROUP 2   B
       9  BLOOD_GROUP 3   O
      10  RH_FACTOR   1   +ve
      11  RH_FACTOR   2   -ve
      12  OCCUPATION  1   Service
      13  OCCUPATION  2   Profession
      14  OCCUPATION  3   Business
      15  OCCUPATION  4   Student
      16  OCCUPATION  5   Unemployeed
  </code></pre>
  
  <p>I want to know that what is a better approach and why. I also have to use hibernate orm in the project. So the design should be pertaining to that.</p>