Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Programming Talk / PHP - MySQL Question

Author
Message
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 11th Oct 2009 18:15
This question doesn't really have anything to do with php, but more to do with MySQL.

For a game i want to make, there is a 2d space system, so each system has a certain amount of x and y sectors, and each value represents a different type of sector. for example

1 2 3 4 5
1
2
3
4
5

This is the grid^ so they are the axis.

now ill add some data, we will say 1 represents deep space, and 2 represents a nebula

This question doesn't really have anything to do with php, but more to do with MySQL.

For a game i want to make, there is a 2d space system, so each system has a certain amount of x and y sectors, and each value represents a different type of sector. for example

1 2 3 4 5
1 1 2 1 1 1
2 2 2 2 2 2
3 1 1 1 2 2
4 2 2 2 1 1
5 1 1 2 1 2

But im unsure how to do this in a MySQL table. Would i create a new field for each value, keeping in mind that the x and y axis could go anywhere for 5 to 20.

Does anybody have any ideas?

Omricon W.I.P
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Oct 2009 21:29
Take a look at the tables below. By using X and Y as primary keys in Sector, you ensure that there are no duplicate coordinates assigned and it makes for quick lookup when searching for a particular sector. The spacialType could be just a number, or it would be an ID referencing an element from the SpacialTypes table. By using the second table to define the spacial types you can describe the data and have more control when defining deep space or nebulas.



Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 11th Oct 2009 23:41
ah right, so store each sector seperatly?

Omricon W.I.P

Login to post a reply

Server time is: 2026-06-10 08:29:17
Your offset time is: 2026-06-10 08:29:17