Any logic to breaking a table into 2?
In my limited experience of working with MySQL I have seen to large apps where user data that was unique and should have been together, but was divided into 2 tables.
eg :
table 1: firstname, lastname, username (20 other similar columns) table 2: user description, likes, role.. (15-20 other columns relating to the same user)I am doing somethin开发者_C百科g similar, where the application I am building is expecting a lot of traffic and a lot of queries.
My question really is, If a table makes sense and has for example 40 or 50 columns, should it still be broken to 2 - 3 tables.
My guess is, more than how the table is structured, the queries that are run on it would be of importance, but, I want to know what you think.
It depends on the data.
If you need all of the datas all the time, there's no point in separate all this in different table.
If you're always filtering the same subset of the result, maybe separating the data will slightly improve the performance.
In my point of view however, the best solution is the one your comfortable with. I don't think there we'll be a noticeable impact on performance with data separation.
Take a look on the queries you're writing, and if it's easier for you to separate the tables, do it, but otherwise don't spend too much time thinking about this.
Some relevant links:
- Advantages to Vertical Partitioning of Table
- Partition (database)
精彩评论