Hi, I am new to database design and for a while now I have been creating an arcade script. I was hoping someone with more experience would be willing to look at a sql dump of my tables and suggest any way in which I could improve it. SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; CREATE TABLE IF NOT EXISTS `categories` ( `Id` smallint(1) NOT NULL auto_increment, `Name` varchar(20) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; CREATE TABLE IF NOT EXISTS `games` ( `Id` mediumint(6) NOT NULL auto_increment, `Category` tinyint(1) NOT NULL default '0', `Swf` varchar(10) NOT NULL, `Name` varchar(30) NOT NULL, `Thumb` varchar(10) NOT NULL, `Width` varchar(3) NOT NULL, `Height` varchar(3) NOT NULL, `Description` text NOT NULL, `Plug` varchar(1) NOT NULL default '0', `Enabled` tinyint(1) NOT NULL default '1', PRIMARY KEY (`Id`), KEY `Name` (`Name`), KEY `Swf` (`Swf`), KEY `Thumb` (`Thumb`), KEY `Plug` (`Plug`), KEY `Height` (`Height`), KEY `Width` (`Width`), KEY `Category` (`Category`), KEY `Enabled` (`Enabled`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; CREATE TABLE IF NOT EXISTS `gamesplugs` ( `Id` smallint(3) NOT NULL auto_increment, `Name` varchar(30) NOT NULL, `Url` text NOT NULL, `Traderid` varchar(10) NOT NULL, `Hits` mediumint(10) NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; CREATE TABLE IF NOT EXISTS `links` ( `Id` smallint(5) unsigned NOT NULL auto_increment, `Password` varchar(20) NOT NULL, `Email` varchar(40) NOT NULL, `Url` varchar(255) NOT NULL, `Name` varchar(255) NOT NULL, `Ref` varchar(200) NOT NULL default 'http://www.nosite.com/index.php', `In2` mediumint(5) unsigned NOT NULL default '0', `Out2` mediumint(5) unsigned NOT NULL default '0', `Enabled` smallint(1) NOT NULL default '0', `Credits` decimal(10,2) NOT NULL default '0.00', PRIMARY KEY (`Id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=1 AUTO_INCREMENT=0 ; Code (markup): Any idea's? Thanks for looking.
What kind of improvement you mean? The structure is just normal. I would only not use smallint for ID. Simply int. And one thing : i do not see on which field tables are connected to each other. This should be clear from the beginning.
Well my aim is to get the database running as quickly and efficiently as possible. I have a good caching system between the front end and database but it is when the cache gets updated that I would like to improve things. I don't understand what you mean by this, please can you give an example?
Than you need good indexing. But indexing depend on what kind of SQL requests you will have. You can start with this DB design and if you face to slow SQL simply add correct keys (with "explain" you can find where is the prioblem) Sorry, I see now that you have in "games" refference to "categories" by field "Category", so it seems everythings is ok.
Hello, i have highlighted what i understood to be key and foreign keys (relations between your table). If indeed these fields are linked (the ones with same color) then you should have them be of the same datatype..