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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:35:23+00:00 2026-05-21T19:35:23+00:00

I am trying to plan my table structure for a business directory where I

  • 0

I am trying to plan my table structure for a business directory where I will have multiple parent categories for multiple sub-categories and multiple business listings, all of which will require a many to many relationship.

eg.

A Night Out

Clubs and Societies
Public Houses
Restaurants
Taxis and Private Hire Vehicles
Theatres and Concert Halls
Wine Bars

Restaurants

Chinese / Oriental
Bistros
Fish and Chips
Indian
Italian
Public Houses
Seafood
Spanish

Transport and Carriers

Air Charter and Rental
Airlines
Car / Van Hire Self Drive
Courier and Distribution Services
Estate / Property Re-location Services
Freight Services and Agents
Haulage Contractors
Post Offices and Services
Re-location Services
Taxis and Private Hire Vehicles
Van Hire

As you can see, Restaurants is both a main category and a subcategory. Taxis and Private Hire Vehicles belongs to both Transport and Carriers and A Night Out and under all of these categories, on the lowest level, I will have the business listings. I will not be allowing businesses to submit their own listings but rather adding them myself upon request. A business listing can belong to a maximum of 6 categories.

I am struggling to find the best structure of tables for my database and would be very grateful for any suggestions. I am relatively new to php/mySQL.

  • 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-05-21T19:35:24+00:00Added an answer on May 21, 2026 at 7:35 pm

    You could have a category table which will contain a list of all possible categories/subcategories and then in your information table have it so that there is a CategoryID field as well as a SubCategoryID where you will either have NULL for the subcategory or the corresponding id.


    You could also map it using a mapping table, that way you will be able to have as many categories / subcategories as you want.

    Category Table ( CategoryId, CategoryName )
    Business Table ( BusinessId, BusinessName )
    Category Mapping Table ( BusinessId, CategoryId, IsCategory )
    

    The IsCategory would be a BIT field so that you can mark any number of categories for a business as either a SubCategory (0) or a Category (1).

    On the Category Mapping Table I would make the PRIMARY KEY ( BusinessId, CategoryId ) as well as make them FOREIGN KEYs to the Business / Category table respectively.

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

Sidebar

Related Questions

I am trying to keep a somewhat organized directory structure as I plan to
I am trying to write a VBA script which imports all of the Excel
I'm laying out my table structure and am trying to make a good educated
I have 2 tables. One table contains all of the states in the USA.
I've been trying to load multiple files into a table, so that they would
I'm trying to analyse a query execution plan in my Oracle database. I have
I'm trying to produce a table that will show the total maturity amounts for
Hi were trying to perform a mysql select which isnt going to plan and
We are trying to create a web-service that we plan to pass a variable
I'm trying to export a copy of the Explain Plan from Oracle SQL Developer

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.