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 8449403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:41:48+00:00 2026-06-10T10:41:48+00:00

I have a database which stores information about a game world. Specifically, I have

  • 0

I have a database which stores information about a game world. Specifically, I have a table to store all the different maps, and another to store the buildings in each map. A map can have 0-n buildings and I store the information as follows:

maps (map_id (PK), map_name)

buildings (building_id (PK), building_name, map_id (FK))

My problem is how to efficiently query the database to obtain the name of a map and all of its buildings. For example, I want to get 10 maps and their buildings.

SELECT * FROM maps JOIN buildings USING (map_id) limit 10

The above query could return 10 rows or 100, but it seems rather wasteful having so much duplication within the result table due to the map_name being repeated for each answer.

Alternatively, I could just get the map_ids first and then perform individual queries for each map. eg.:

SELECT map_id from maps limit 10

foreach map+id: SELECT * FROM buildings WHERE map_id = x

However, this again seems wasteful as I’m performing 11 separate SQL queries?

So to sum up, the first method seems memory/bandwidth inefficient, the second seems CPU inefficient. Am I right and is there a better way?

  • 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-10T10:41:49+00:00Added an answer on June 10, 2026 at 10:41 am

    I wouldn’t worry about the memory/bandwidth being inefficient in your first query, this is what a relational database is designed for. Your tables are properly normalized so you are going to need to use a join to pull data from both tables. The fact that the map name and ID gets repeated on each row is trivial until you start having tens of thousands of maps and even then, it’s probably not a big deal.

    Now if you are going to display this information in a GUI so that the user could view it you might want to go with two separate queries – one to get the list of maps and then a separate query to get the list of buildings once the user has selected a map. If you give us an idea of what exactly you are trying to do we might be able to give better advice.

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

Sidebar

Related Questions

I have a database which stores (among other things), the following pieces of information:
I have a database table A which stores records, A has a primary key
I have table in my SQL Server database called OrderDetail which stores the order
I have the situation where i use GIS software which stores the information about
I was given a database design which stores information about an organization and any
I have created sqlite database which stores Latitude,Longitude and some other information like description.
I have a database which needs to store year ranges (such as lifespan) which
I have a database in which I'd like to store an arbitrary ordering for
I have a database in my application in which I store something like a
I currently have a MySQL database which I was hoping to use to store

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.