PDA

View Full Version : Auto increment or independant id? Mysql



benjaminj88
08 Sep 2010, 06:44 PM
So here's what I'm trying to do. More or less I am building a map editor using php and mysql, now the table has the following columns: id, xAxis, yAxis, zAxis, type, contents. With those stated I was thinking and it would be much simpler to essentially have the cordinates create the unique id. So it would display like so: x:33;y21;z;-2;.

Here's what I am wondering though how exactly would I break it appart to use each axis point for displaying the map? Or should I just simply remain using the individual points in their own column and use an auto increment for the id?

Alan
09 Sep 2010, 07:42 AM
A co-ordinate seems to be a unique identifier in your case. I assume you are looking for a primary key. You can create a multiple column primary key, so just use the three columns (xAxis, yAxis and zAxis) as your primary key.

There's no need to extract the data from a single column as the co-ordinates are still in separate columns.