atrum Posted November 21, 2010 Share Posted November 21, 2010 Just want to get peoples opinions on the recommended way to go about this. I am attempting to build a guild management tool using php. (for wow in case your curious) and I want to store the classes, races, and any other static data for use in lists, and other functions. I was thinking of just setting up a static table for classes, but I think that might be a waste of resources. The other way would be to store them all in a static array in a config file. What is the best practice route to take on something like this. I am leaning more towards the config file. Quote Link to comment https://forums.phpfreaks.com/topic/219392-database-vs-config-file/ Share on other sites More sharing options...
ignace Posted November 21, 2010 Share Posted November 21, 2010 Everything depends on how you want to use the data. Most certainly you want to avoid people specify invalid class names so your database should be something like: CREATE TABLE Classes ( class_id VARCHAR(32) NOT NULL, -- class name PRIMARY KEY (class_id) ) ENGINE=INNODB; CREATE TABLE Characters ( character_id VARCHAR(32) NOT NULL, -- character name class_id VARCHAR(32) NOT NULL, .. PRIMARY KEY (character_id), FOREIGN KEY (class_id) REFERENCES Classes (class_id) ON UPDATE CASCADE ) ENGINE=INNODB; If you are playing against a specific version then you could use: CREATE TABLE Characters ( character_id VARCHAR(32) NOT NULL, -- character name class_id ENUM('<class-id-1>','<class-id-2>') NOT NULL, .. PRIMARY KEY (character_id) ) ENGINE=INNODB; This makes it easy to manage it from a back-end. The first example will allow you to easily also add classes the second one doesn't and will make it costly to do so. I do not recommend using a config file instead you could use: class RaceClass { private $validClasses = array( .. ); } Quote Link to comment https://forums.phpfreaks.com/topic/219392-database-vs-config-file/#findComment-1137628 Share on other sites More sharing options...
atrum Posted November 21, 2010 Author Share Posted November 21, 2010 Thanks for the advice , I am thinking the class might be the best route for this since those have only changed once in the 5 years wow has been out (they added death knights). Not only that but I won't be allowing users to type in their class, they will only be able to select from a pre-compiled list (drop-down). Thanks man, your input is always helpful. Quote Link to comment https://forums.phpfreaks.com/topic/219392-database-vs-config-file/#findComment-1137634 Share on other sites More sharing options...
ignace Posted November 21, 2010 Share Posted November 21, 2010 Thanks man, your input is always helpful. Glad I could help Quote Link to comment https://forums.phpfreaks.com/topic/219392-database-vs-config-file/#findComment-1137637 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.