0

I have a table user profile build in Mysql, it contain many optional columns. (around 30 columns)

id, tel, live, mob, email...

Q1. should I store it in 30 tables(use join) or store it in 1 table?

if 30 tables

it can save many empty fields if user didn't save the data.

Q. When I query, this will require join 30 times, will this bad for performance instate just select 1 table and query. (it will be more difficult to write for each query)

if 1 table

There are going to be many empty fields in columns

Q. Should I store it in NULL or "empty"?

Ben
  • 2,562
  • 8
  • 37
  • 62

1 Answers1

0

Q1. should I store it in 30 tables(use join) or store it in 1 table?

No this would not be a good idea

Q. When I query, this will require join 30 times, will this bad for performance instate just select 1 table and query. (it will be more difficult to write for each query)

Yes this will badly impact your performace

In general you want to have your tables relatively small (my opinion) but you should group related values, for a user you might want: username, email, password, last_login etc..

While 30 columns seems a bit high there may be a valid reason for it, but if you find that many fields are empty most of the time then you should reconsider your design. What is the situation when those fields are not empty? for example if those fields are not empty only when the user has entered their address info then perhaps you should make an address table.

this post adresses well the null vs empty question: MySQL, better to insert NULL or empty string?

Community
  • 1
  • 1
Dallas Caley
  • 5,367
  • 6
  • 40
  • 69