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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:47:27+00:00 2026-06-01T22:47:27+00:00

I have a problem that I cannot seem to find a solution for. I

  • 0

I have a problem that I cannot seem to find a solution for. I have browsed similar answers around here, but nothing was exactly what I was looking for. I am fairly familiar with SQL, but not an expert by any means.

I have a table with information about apartment buildings – name, area, neighborhood, phone number, address, zip, etc. Currently, I have several amenities defined inside this table, such as “doorman”, “elevator”, “gym” (and few others) as tinyints to indicate whether the building does indeed have that amenity or not. However, I am in the process of incorporating many more amenity types and I figured that this might the time to change the structure as adding a column to a huge table of buildings does not make too much sense.

So I am looking for a solution that would provide me with the best ability to do the following:
1) search for a building based on user defined amenities (for example user selects that he wants to see buildings that must have a gym and a doorman, doesn’t care about the others)
2) return the data about the building including all of the amenities that the building contains (for displaying information)

I was thinking about separating these structures into a many to many relationship and doing the following:
1) creating new table called “amenities” that would contain all of the amenities have the following structure:
id -> unique id of the amenity
name -> text description of the amenity
value -> for example “pet_friendly” (for searching in forms, not sure if necessary)

2) creating a relationship table between buildings and amenities in another table called “building_amenities” with the following structure:
id -> unique id of the relationship
building_id -> refers to an id of a building
amenity_id -> refers to an id of an amenity
value -> tinyint, whether the building has the amenity or not
In this table each building would have a relationship to each amenity and indication whether it has it or not.

My problem is that I am not sure if this is the correct structure for this situation and I certainly have no clue how I would implement search queries if I had this structure.

Thanks a ton for any help with this!

  • 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-01T22:47:29+00:00Added an answer on June 1, 2026 at 10:47 pm

    I would recommend that you create a buildings table, an amenities table and a relational table. Each building has an ID, as does each amenity. To select all buildings with certain amenities present, you would simply write a query as follows

    SELECT *
    FROM (relational_table) rt JOIN (buildings_table) bt
        ON rt.id_building = bt.id_building JOIN (amenities_table) at
        ON at.id_amenity = rt.id_amenity
    WHERE rt.id_amenity = ... (OR, AND etc.)
    

    To return a building with its amenities you simply change the WHERE clause to WHERE id_building = x and then all the amenities should be selected in.

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

Sidebar

Related Questions

I have a simple problem that I cannot seem to find a solution to.
I have a small problem that I cannot seem to wrap my head around
I have a problem that I cannot seem to find an answer to. With
I have a very simple C# DataTable problem that I cannot seem to wrap
It is known that the halting problem cannot have a definite solution, one that
Perhaps there is an easy solution for my problem but I simply cannot seem
I have been looking everywhere but cannot find a clear solution for the following
I have a simple problem that i cannot solve. I have a dictionary: aa
I am new to python and I have a serious problem that I cannot
I have a little newbie problem that I cannot figure out, I am having

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.