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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:39:55+00:00 2026-06-13T17:39:55+00:00

I have a Business model in my application, which will be storing information about

  • 0

I have a Business model in my application, which will be storing information about

  • Restaurants
  • Bars
  • Stores
  • Hair Salons
  • Etc

Some of the businesses share attributes/amenities:

  • Wifi
  • A/C
  • Accesibility
  • Etc..

But some are specific for a single type of businesses, for example restaurants:

  • Take out
  • Delivery
  • Dress code
  • Outdoor seating

I am wondering what would be the best way of modelling this information in the DB?

My current thinking:

Use a single table for Business that will hold all the information and attributes. Most of the attributes are boolean, therefore whenever an attribute does not apply to a business type, it will simply be false.

I am not sure however, if there is a better way of doing this. Also not sure about how to handle these differences at the view level. For example, when creating a business, I want the option the display/set those attributes that are applicable to the business type.

  • 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-13T17:39:56+00:00Added an answer on June 13, 2026 at 5:39 pm

    That is the way I would do it. You should have an attribute called business_type that lets you choose what attributes to display.
    For example in the show view:

    <% if @business.business_type == "restaurant" %>
      Provides take out: <%= @business.take_out %>
    <% end %>
    

    You could use jQuery to change what fields are available on the new form based on what restaurant type it is:

    <%= f.select :business_type, [["Restaurant", "restaurant"], ["Store", "store"]] %>
    <script>
      $('#business_business_type').change(function(){
        // hide or show fields here based on this.value
      });
    </script>
    

    If you want to avoid having a bunch of database columns, you could use the key-value store in rails 3.2 (3/4 of the way down this page):
    Make a column called amenities. Then in business.rb:

    store :amenities, accessors: [:wifi, :ac, :accessibility, ...]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to decide about a new big business application we will develop in
I have a pre-existing c++ object model which represents the business layer tier of
I'm working on a web-based business application where each customer will need to have
I have been asked to develop an application which will use data available from
I have made an application recently which has articles, etc, with a commenting/moderation system
i have few controllers within my application which uses too much of business logic
In my business model I have Entity class (IPoint interface ) that has a
I have a basic Django model like: class Business(models.Model): name = models.CharField(max_length=200, unique=True) email
I have a model called Business , and I want to save Business.all into
I have a business object project, which contains composite structure: public class Tree {

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.