i design database logging system.
many of string columns have limited amount of values, not known in advance: name of modules sending messages, or source hostnames.
i store them mysql enums save space. idea enums grow encounter new values.
i start column :
host enum('localhost')
then, in java, load on startup enum values defined hostnames @ time (how do mysql/jdbc ??), , alter enum whenever encounter new host.
do think feasible / idea ? have ever done ?
thanks in advance advice.
raphael
this not idea. enum designed not that. can create separate table (host_id, host_name) , use refference in main table. example:
create table `host` ( `host_id` int(10) not null auto_increment, `host_name` varchar(50) null default null, primary key (`host_id`) ) create table `log` ( `log_id` int(10) not null auto_increment, `host_id` int(10) null default null, ... primary key (`log_id`), index `fk__host` (`host_id`), constraint `fk__host` foreign key (`host_id`) references `host` (`host_id`) on update cascade on delete cascade )
upd:
i think best way storing host varchar/text field. easiest , fastest way. think need not worry space.
nonetheless.
using second table hosts reduce size, complicate writing logs. using enum complicate writing , reduce performance.
Comments
Post a Comment