Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Best way to deal with thousands of static entries

    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?

    Thanks!

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    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.

  • #3
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    I agree, a database with tables for category and item, with item having categoryid as foreign-key is the best solution.

  • #4
    New to the CF scene
    Join Date
    May 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Great, thanks so much for the input.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •