mysql - Table with many columns or many small tables? -


i created table has 30 columns.

create table "settings" (   "column1" integer primary key,   ...   ...   "column30" ) 

however, can group them , create different table can have foreign keys primary table. best way follow? or number of columns small it's same way follow?

it depends on data , query do.

best 1 big table

  • if need extract columns always
  • if need update many fields @ same time
  • if fields or quite have not null values

best many little tables

  • if data "sparse" means not many columns have values can imagine split them in different tables , create record in child table if not null values exists
  • if extract few related fields @ 1 time
  • if update related fields @ 1 time
  • better names each column (for example instead of domicile_address , residence_address can have 2 columns named address in 2 tables residences , domiciles)

the problem can use both solutions depending situation. usage analysis must done choose right one.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -