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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:40:10+00:00 2026-05-25T18:40:10+00:00

Let me explain, take an inventory system. You have items and you have rooms.

  • 0

Let me explain, take an inventory system. You have items and you have rooms. If I have a table for items, that means everyone’s data gets inserted into the same table. Hence, the primary key (item_id) is auto_incremented by 1. So “John” signs up two weeks later and his first item’s id might be 210. How can I go about giving each user their own “id?” Without resorting to creating their own table, which could get messy if I have 1,000 users.

| item_id | item_name | user_id |
|    1    |  sofa     |    1    |
|    2    |  ps3      |    1    |
|    3    |  ipad     |    1    |
|    4    |  laptop   |    2    |

Example URL:

http://domain.com/item/view/1

John would get a URL of http://domain.com/item/view/210 for his first item.

In case this helps someone else, here’s what i ended up doing.

Create a mapping table. In my case, “users_items” with item_id and user_id and remove the primary key.

SELECT case when item_id IS NULL then isnull(max(item_id)+1) else max(item_id) +1 end as item_id 
    FROM users_items WHERE user_id = $user+id;
  • 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-25T18:40:10+00:00Added an answer on May 25, 2026 at 6:40 pm

    Maybe create an additional column item_code which you can populate with something like

    SELECT ISNULL(MAX(item_code) + 1) FROM item
    WHERE user_id = 2
    

    Considering item_id is a surrogate key it shouldn’t matter what value it is, the user has no concern about that, but item code can be the code for the user to display.

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

Sidebar

Related Questions

Let me explain best with an example. Say you have node class that can
First let me explain. I have several addresses on the page that I put
I think, it is easier explain using an example. Let's take a class that
Let me explain you my situation. I have a base class called Shape, and
let me explain my current situation i have a SharePoint site lets say it
Let me explain what I mean : Let's say we have a menu with
Let me explain my scenario first: I have around 2000 tests to run, which
Let me explain. I have defined an interface named IEmployee (ID, FirstName and Surname
Let me quickly explain. I have an application to manage visitors. We have a
I have a single value in a table that I want selected every time

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.