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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:20:26+00:00 2026-05-30T00:20:26+00:00

Table locations contains locID , lat & long & name values of a certain

  • 0

Table locations contains locID, lat & long & name values of a certain location.

Table categories contains ID, category-name & locID.

How do I make categories assignable to multiple locations?

It doesn’t make sense to have the same category stored multiple times, once for every locID.

  • 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-30T00:20:27+00:00Added an answer on May 30, 2026 at 12:20 am

    You can use a join table to model the many-to-many relationship.

    location_category
    location_id   category_id
    1             1
    1             2
    2             1
    2             3
    3             4
    

    Add foreign key constraints to prevent invalid values from being entered into the table:

    • From location_category.location_id to locations.locID
    • From location_category.category_id to categories.ID

    Also make (location_id, category_id) the primary key for the table to prevent adding a category to the same location multiple times.


    When reading the data from the table, use JOINs to get the related data from the main tables:

    SELECT ...
    FROM location_category
    JOIN locations ON location_category.location_id = locations.locID
    JOIN categories ON location_category.category_id = categories.ID
    WHERE ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table contains 300 locations name (Pris, London,...) is there a way
I a table or locations and user query to find there location. The issue
I have a database table which link locations together; a location can be in
I have 3 tables event, location, event_location. Event can have multiple locations. Location table
I have a table MYTABLE. This contains customers and locations. What Sql statement can
I have table which contains columns like SiteID (identity_Col) SiteName POrderID Location Address Cluster
I have a table of locations with latitude, longitude and the U.S. state fields.
I want to store the distance between different locations in a table. CREATE TABLE
A location table record has two address id's - mailing and business addressID that
i have latitude and longitude columns in location table in PostgreSQL database, and I

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.