Saturday, 15 August 2015

mysql - Better Database design for hibernatre? -


I am new to database design I am using a MySQL

form is a table in which a field is country

because it can contain values ​​in this column from only one country list, so I varchar Instead of creating this column int and putting the list in a new table.

country varchar (255) do not tap

  1. ol start = "2">
  2. I It has created COUNTRYCODE with datatype INT and added a foreign key to the table CountryMaster which

... countryCode INT No NULL, Foreign Key (Country Code) Reference CountryMaster (cOUNTRYCODE), ...

Table CountryMaster create (countryCode INT not NULL Primary key AUTO_INCREMENT, name VARCHAR (255)) ;

This is working fine, but the point is that formStatus (with possible value drafts on the same table, there are many more columns like saved , gender , blood group (A, B, O), rHFactor (+ ve, -ve) Business (service, business, student, unemployed) etc. If I create a separate table for each such column then I will get 20 to 25 Master tables.

In addition to this, all Master's dates in a table, such as CommonMaster , type, key and value are shown below, Tried to insert:

create table CommonMaster (commonCode INT not NULL primary key AUTO_INCREMENT, type VARCHAR (255) No NULL, key INT not NULL, value VARCHAR (255) NULL); With values ​​like:

  Code type key value 7 BLOOD_GROUP 1A8 BLOOD_GROUP 2B 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 Oak Appointment 5 Unemployed  

I want to know what a better approach is and why do I The design should be in hibernation, so the design should be related to that.

I like hundreds of master tables compared to a normal table with all; More adaptive to more structure, more organization, report, add, remove, and update afterwards.


No comments:

Post a Comment