views:

41

answers:

1

Could I get some opinions on this MySQL table structure please?
Is the amount of varchar fields bad? Are there better alternatives?

The kind of data should be fairly self-explanatory.

CREATE TABLE `users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `active` bit(1) NOT NULL DEFAULT b'1',
  `email` varchar(64) NOT NULL,
  `password` char(128) NOT NULL,
  `forename` varchar(32) NOT NULL,
  `surname` varchar(32) NOT NULL,
  `ip` int(10) unsigned NOT NULL,
  `address` varchar(32) NOT NULL,
  `address_2` varchar(32) DEFAULT NULL,
  `city` varchar(32) NOT NULL,
  `county` varchar(32) NOT NULL,
  `postcode` varchar(16) NOT NULL,
  `country` char(2) NOT NULL,
  `country_other` varchar(16) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `email` (`email`),
  KEY `password` (`password`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

Thanks!

A: 

You can try using text in varchar in the address fields, possibly the email one too. I've read some problems about symbols (@) in the varchar field. With text you don't have to define a size as far as I know.

John H.
using text columns could impose other issues. I know in SQL Server, text column data is stored off-row.
Sage
Thanks for the heads up!
John H.