Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to store variable information about a business in database
    primarykey
    data
    text
    <p>I'm trying to create a website similar to Yelp (smaller scale, smaller market) and right now i'm in the database design stage and was wondering how to model the tables for storing the 'additional business info' features that are occasionally found under some business listings such as:</p> <ul> <li>nearest transit (text) </li> <li>accepts credit card (Y/N) </li> <li>has wheelchair access (Y/N)</li> <li>good for kids (Y/N)</li> <li>parking (enum type - street, garage, etc)</li> <li>attire (enum type - casual, formal, etc) </li> <li>delivers (Y/N) </li> <li>etc</li> </ul> <p>bearing in mind that some of this info only pertains to businesses of a certain category e.g. the <em>attire</em> and <em>delivers</em> info might only apply to say, businesses in the restaurants category so it wouldn't make sense to store everything in the main <em>businesses</em> table.</p> <p>What I'm wondering is how to store these extra features/additional information about a business since they are not applicable to all businesses and not in all cases.</p> <p>I was thinking of putting each feature in it's own table and linking to the main businesses table through the *biz_id* FK e.g.</p> <pre><code>Businesses ------------- biz_id (PK) name website isnew ... Biz_accepts_credit_card ----------------------- biz_id (FK) accepts_credit_card (bit field) Biz_parking (biz can have multiple parking types) ----------- auto_id (PK) biz_id (FK) parking_type {any combination of: street,garage,valet,etc} ... </code></pre> <p>My thinking was that while this would create a large amount of tables just for storing this additional info, it would also be pretty flexible, especially in terms of adding new info/features further down the road, but it would probably mean that I would have to be joining lots of tables (15+ in worst case) just for this info :/</p> <p>I was also wondering if the various categories a business could fall into would have any bearing on this as well.</p> <p>EDIT: After reading the response from @Daveo</p> <pre><code>Features{id, name, ismultiVal} (defines all possible features) FeatureValues{id, feature_id, value} (defines the possible values each feature can have) BusinessFeatures{id, biz_id, feature_id, feature_value} (stores the features applicable to each business) CategoryFeatures_{category_id, feature_id} (what features are found in which categories) FeatureReviews_{review_id, feature_id, feature_value} (stores the feature values that users voted on in their review of a business) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload