Jump to content

Large Table Vs Multiple Tables


dcace

Recommended Posts

I've very new to mysql but have used it with php to create an online browser based space game. I'm about to expand by game but don't know the best way to use the database. Currently there are 10,000 records in a table called db_sectors (1.3MB) which represents all of the sectors of space in the game. This table is access heavily by the game as each nearly each page the player views shows a 5x5 grid of the galaxy so 25 records have to be accessed. I want to make the game bigger by going from 1 galaxy of 10,000 sectors to 25 galaxies of 10,000 sectors making a total of 250,000 sectors.

 

Should I have all the sectors in one table with a galaxy_id field to represent which galaxy the sector is from like:

 

db_sectors

 

db_sectors.sectors_id

db_sectors.sectors_galaxy_id

db_sectors.sectors_x

db_sectors.sectors_y

 

or have 25 tables like:

 

db_sectors1

 

db_sectors1.sectors_id

db_sectors1.sectors_x

db_sectors1.sectors_y

 

db_sectors2

 

db_sectors2.sectors_id

db_sectors2.sectors_x

db_sectors2.sectors_y

 

I'm worried that having 250,000 records in one table will slow the game down as the database will not be able to access the records as fast as it would with 25 seperate tables. I know very little about how mysql works and have gotten by so far with basic tutorials and lots of trial and error. Any help would be appreciated.

Link to comment
Share on other sites

250,000 records isn't a lot of records with you use indexing properly. You can also do what your wanting to do as long as you keep your relationships. What I mean is that a user has the ability to cross over into different sectors by your application doing some type of join. Many times people have their own reasons for using many tables, like say you have a city database and each city has a state_name, you could list the state_name column in the cities table, but to save space, you can also create a states table and put your state_name in their, then assign the cities table a tinyint(2) column that has a relationship with the primary key in the states table and use a join to get the state_name. If you 50,000 records you just saved your self a bunch of space, without hurting your application processing time.

 

But for being faster or less intense, when using more tables, I don't see it as being beneficial in your case because overall all the tables would be the same, the only difference being the sector!

 

printf

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.