mardi 31 mars 2015

At what number of columns should you make another table?

I had a table that nearly reached 20 columns.


I find each one necessary since it's a "project" table, and the project has columns that indicate stuff such as when it was created, when it was updated, its id, who started it, who finished it, some metadata such as keywords, the content of the project itself, a brief description and some other stuff.


I was happy with my table, but then I browsed some questions through stackoverflow and saw stuff like "your table should never have more than 10 columns" and suggestions that if it was the case, you should split your table into smaller ones.


Following StackOverflow's advice, I split my table into two tables, but I'm finding it more complicated to manipulate. Now, when each project is created, I have to create two new records, each one for each table. I have to handle errors on the creation of either record, which means that if the creation of the record on the second table fails, I have to do yet another query to rollback the creation of the first record. Data retrieval and record deletion has also been made more complex, since now I have to do that on two tables.


I'm using the Sails.js framework, and trying to use associations, but I find that it's pretty much the same, I still have to repeat tasks for each table.


Is it really worth it to split your table into smaller ones if it gets that big? Or should I just keep my 20 column table? My project is new, not even online, so I don't know performance. I've never understood associations/joins or databases in general, as in, I've never understood why people do it, so, what are the benefits?


Thanks.


Aucun commentaire:

Enregistrer un commentaire