1

I am using mysql with php Yii framework.When doing data modelling I came accross some doubt.I have a table for user details like this.

CREATE TABLE IF NOT EXISTS `tbl_users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `firstname` varchar(80) NOT NULL DEFAULT '',
  `lastname` varchar(80) NOT NULL DEFAULT '',
  `gender` varchar(6) NOT NULL DEFAULT '',
  `email` varchar(45) NOT NULL DEFAULT '',
  `company_name` varchar(80) NOT NULL DEFAULT '',
  `contact_no` varchar(45) NOT NULL DEFAULT '',
  `address` varchar(120) NOT NULL DEFAULT '',
  `state` varchar(45) NOT NULL DEFAULT '',
  `country` varchar(45) NOT NULL DEFAULT '',
  `created_by` int(11) DEFAULT NULL,
  `updated_by` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=98 ;

Here my problem is I want the state,country should be like this so that I can use the fields like state/city

 `state/city` varchar(45) NOT NULL DEFAULT '',
  `state/province` varchar(45) NOT NULL DEFAULT '',

So is it safe to use like this or I have to use only one option there?Any help and suggestions will be highly appriciable.

3

Currently on MySQL 5.5+ you can use such characters on both schema names and table names, just have in mind that there are known bugs caused by such characters being confused with directory paths on the MySQL internals code base.

Up until MySQL 5.5 you would find it to not be possible. From this link: (of the old documentation, that's not available anymore)

Database and table names cannot contain “/”, “\”, “.”, or characters that are not permitted in file names

One way or another, using backslashes is just bad-practice, I recommend that you use an underscore character instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.