mysql - Using ENUM datatype in many columns with list of values is good practice? -
i developing dating website. in project use mysql table named "users" , table have used enum datatype many columns.
my "users" table looks :
create table if not exists users ( user_id smallint unsigned not null auto_increment, country_id smallint unsigned not null, username varchar(20) not null, password char(128) not null, salt char(128) not null, email varchar(40) not null, first_name varchar(30) default null, last_name varchar(30) default null, sex enum('male', 'female') default 'male', dob varchar(10) not null, mobile varchar(12) default null, address varchar(40) default null, address_two varchar(40) default null, city varchar(25) not null, whoami varchar(80) not null, looking_for enum('short-term','long-term','marriage','dating','friends/hang out','intimate encounter','talk/email/pen pal','activity partner') default 'dating', ethnicity enum('white/caucasian','black/african','hispanic/latino','asian','native american','middle eastern','east indian','pacific islander','mixed race') default null, marital_status enum('never married','divorced','widowed','separated','in relationship','not single/not looking') default null, religion enum('atheist','buddhist/taoist','christian/catholic','christian/protestant','christian/lds','christian/other','hindu','jewish','muslim/islamic','new age','non-religious','agnostic','spiritual not religious','other religion') default null, body_type enum('skinny','slim/slender','fit/athletic','toned & firm','muscular','ripped','modelesque','average','proportional','curvy','few pounds','full figured','stocky','husky','voluptuous','big , beautiful','large','disabled') default null, hair_color enum('auburn','red','stawberry blonde','platinum blonde','blonde','dark blonde','light brown','medium brown','dark brown','black','radically dyed','salt & pepper','partial gray','gray','silver/white','bald/shaved') default null, drink enum('never','rarely','occasionally','socially','regularly','gave up') default null, smoke enum('never','socially','regularly','trying quit') default null, headline varchar(100) default null, about_user text default null, ideal_match_info text default null, last_login timestamp not null default '0000-00-00 00:00:00', date_registered timestamp not null default current_timestamp, primary key (user_id), unique (email), unique (username) ) engine=myisam default charset=utf8; my question is, enum datatype have used in table correct or not. if correct way hope body guid me right direction.
thank you.
this not way use enum. it's you'll have change options, , way change enum costly , error-prone alter table. store option text instead (varchar or tinytext). normalization perspective better create separate tables options makes data harder understand.
the enum data type best used cases when options guaranteed not change.
Comments
Post a Comment