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.
Yes, it’s valid. But you will always need to quote it with backticks.
See http://dev.mysql.com/doc/refman/5.5/en/identifiers.html for full details on what’s allowed.