View Full Version : Best way to deal with thousands of static entries

05-17-2006, 06:24 AM
Let's say I'm making an online game where players are able to collect items. Thousands of these items will be available and their attributes will be static. At first, I had the items in a database, where I skipped id numbers to separate the type of items (I did this by 1000s so I'd have room to add more). The setup looked something like this:

id | item
1 gun1
2 gun2
1001 laser1
1002 laser2
2001 missile1
2002 missile2

and so on

After thinking about the setup, I moved them out of a database (database should be for dynamic data) and into one big array , which is in an include file.

Now I've got a huge array of thousands of items that I'm including in most of my php files and I'm worried about file size implications and performance.

What would be the best way to deal with a scenario like this where one has thousands of static entries broken down into categories?

- Go back to the database?
- Put everything in a big array?
- Make separate arrays for each item type (1000/array)?
- Some other method?


05-17-2006, 03:45 PM
put it in the database. data in the database doesn't have to be dynamic. if it helps you manage your data and retrieve it faster then that will be a good use of the database as well.

05-17-2006, 04:05 PM
I agree, a database with tables for category and item, with item having categoryid as foreign-key is the best solution.

05-18-2006, 02:08 AM
Great, thanks so much for the input.