4

So,

I needed a settings table to manage some parts of my web app.

I came up with this:

CREATE TABLE `settings` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `key` char(55) NOT NULL DEFAULT '',
  `value` longtext NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `key` (`key`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

enter image description here

I was wondering if it would be beneficial, to divide settings into int and text containign ones. So I would have everything but words_stop etc in another table.

What do you think? is it beneficial? or I can just stick to longtext and have everything in the same table?

4

2 回答 2

0

There's no real point in separating them out, no.

The two main benefits you gain by storing numbers as a number type is you sometimes end up storing less actual bits, and it's easier to perform math on actual number types in some DBMSs. I doubt you'll be running into space issues, and I doubt you'll be doing math with these values. It's not worth separating them out, it'll just get messy.

于 2013-10-27T08:46:52.063 回答
0

I dont think that would affect too much as far as performance is concerned. If you are creating another table to store the text then infact you will need one more column to store the foreign key and then linking the table to your settings table.

This could be beneficial in case when you have a very huge table and there are many columns in the table and you are selecting the values from the table using *

于 2013-10-27T09:00:10.240 回答