Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9135601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:50:46+00:00 2026-06-17T08:50:46+00:00

I am trying to store information about a game map in a MySQL database.

  • 0

I am trying to store information about a game map in a MySQL database. To do this, I will have a VARCHAR field for each map containing an array of integers. This array of integers will contain maybe 1000 numbers corresponding to the id’s of different graphical elements stored in the database.

For example, it may contain a 2d array like this (a 3×3 cell map)

1,1,4
2,5,6
1,1,1

There would then be a table in my database like this

tiles
id   |   file      |  desc          | other data //...
 1      grass.png     a grass tile
 2      water.png     a water tile

When a user queries the database for the map, I need to send the 2d array as well as the information about the elements. e.g. if the array contains the number 2, I need to return information saying that any cell with id 2 should be drawn as a water tile, file name water.png etc.

How is best to implement this efficiently? I don’t really want to have to go through the entire array in php, get the unique id values and query the database again for the information afterwards (seems inefficient to me).

I was thinking about having another field containing the unique ids in the format 4,1,2,5,6 that would be updated whenever the 2d array was altered. If this is a good idea, how can I query using it? something like this below doesn’t seem to work for me

SELECT * FROM tiles WHERE id IN ( SELECT unique_ids FROM mapInfo WHERE id = ..)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:50:46+00:00Added an answer on June 17, 2026 at 8:50 am

    Basically, using comma delimited lists in column data is very inflexible. Anytime you think you should create a comma delimited list, you probably should create a new table and put each item in that list in a separate row then relate that new table back to the original table.

    I would suggest you create a table called “cell” with the following columns:

    CREATE TABLE cell (
      row INT NOT NULL, 
      col INT NOT NULL, 
      tile_id INT NOT NULL,
      PRIMARY KEY (row, col)
    );
    

    Then you would query the 2d array with tile information like this:

    SELECT c.row, c.col, t.*
    FROM cell c
    INNER JOIN tile t
      ON c.tile_id = t.id
    ORDER BY c.row, c.col;
    

    If you wanted to have multiple “levels” or “maps” add a map_id column to your cell table so you could keep them separate. You should also add that column to the beginning of the primary key and you would query like this:

    SELECT c.row, c.col, t.*
    FROM cell c
    INNER JOIN tile t
      ON c.tile_id = t.id
    WHERE c.map_id = 2  -- or whatever map you are looking for
    ORDER BY c.row, c.col;
    

    You might even want to keep a map table so you can store a name for each map, possibly the dimensions (100×100, 200×300, etc), etc.

    Just some thoughts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make this 2-player web game application using Spring MVC. I have
I'm trying to build a form gathering information about new player in a game.
I'm currently trying to use ASP.Net Profiles to store additional user information about users
I'm trying to create a query that pulls information about sellers from my database,
I am trying to store information about a class with a template struct with
I am trying to create a multi-dimensional array which will store 'customer' information, where
I'm making a game in c++ that will need to store and retrieve information
I am trying to read a file and store the information in unsigned char
I am trying to match information stored in a variable. I have a list
I'm trying to store an image into an SQL database without using temporary files.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.