When working on a game, I developed a database that used X/Y coordinates, roughly as:
CREATE TABLE Map
(
MapId INT IDENTITY PRIMARY KEY,
X INT NOT NULL,
Y INT NOT NULL,
North INT FOREIGN KEY REFERENCES Map(MapId),
South INT FOREIGN KEY REFERENCES Map(MapId),
East INT FOREIGN KEY REFERENCES Map(MapId),
West INT FOREIGN KEY REFERENCES Map(MapId)
);
(I'm not at my editor, so that may have syntax errors.)
I then implemented the path searching algorithm (A*, specifically) inside a stored procedure.
Is there a better way to implement this coordinates system?
I had implemented it in SQL Server, since that is what I had on hand and what I was familiar with. Is there anything in another database system that would've simplified this problem?
It may make a difference to know that this, being a game, is strictly a grid system. That may simplify (or complicate) the problem.
Edit:
Some sample data:
map_id x y north east south west
----------- ----------- ----------- ----------- ----------- ----------- -----------
20 502 501 26 33 21 18
21 502 502 20 22 87 19
22 503 502 33 23 88 21