mysql table with 40+ columns

前端 未结 4 1734
旧巷少年郎
旧巷少年郎 2021-01-20 20:55

I have 40+ columns in my table and i have to add few more fields like, current city, hometown, school, work, uni, collage..

These user data wil be pulled for many m

4条回答
  •  梦毁少年i
    2021-01-20 21:46

    I have a general comment for you,

    Think about it: If you put anything more than 10-12 columns in a table even if it makes sense to put them in a table, I guess you are going to pay the price in the short term, long term and medium term.

    Your 3 tables approach seems to be better than the 1 table approach, but consider making those into 5-6 tables rather than 3 tables because you still can.

    Move currently, currently_position, currently_link from user-table and work from user-profile into a new table with your primary key called USERWORKPROFILE.

    Move locale Information from user-profile to a newer USERPROFILELOCALE information because it is generic in nature.

    And yes, all your generic attributes in all the tables should be int and not varchar. For instance, City needs to move out to a new table called LIST_OF_CITIES with cityid. And your attribute city should change from varchar to int and point to cityid in LIST_OF_CITIES.

    Do not worry about performance issues; the more tables you have, better the performance, because you are actually handing out the performance to the database provider instead of taking it all in your own hands.

提交回复
热议问题