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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:26:26+00:00 2026-05-29T10:26:26+00:00

imagine a database setup, where x customers can make y orders. normally all customers

  • 0

imagine a database setup, where x customers can make y orders.
normally all customers would share one set of auto incremented order IDs.

  • the first order of customer A has order id #1
  • first order of customer B has order id #2.

i’d like to have individual sets of order IDs for each customer. it is important, that customers cannot see based on the id how many other customers have made orders.

  • first order of customer A has order id #1
  • second order of customer A has order id #2
  • first order of customer B has order id #1

right now, the only way i can see would be to manually select the max value for the customer’s order number, add +1 and then insert it manually.

select max(customer_order_id) from orders where customer_id = X

how can i create this approach in a sense of data integrity and normalization? like having some kind of auto increment for the individual order ids of the customer?

create table customers
(
  id int auto_increment primary key, 
  name varchar(255)
);

create table orders
(
  id int auto_increment primary key, 
  customer_id int
  customer_order_id int 
  foo varchar
  bar varchar
);
  • 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-29T10:26:27+00:00Added an answer on May 29, 2026 at 10:26 am

    Just make the order number the customer number followed by a sequence number. So if I’m customer 103985, my first order is 103985-0001, my second order is 103985-0002. Normalize the data — in an order, store the customer number and the sequence number separately. Combine them for display.

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

Sidebar

Related Questions

Imagine I have a database with one table, this table has only one field
Imagine following situation: There is a distributed key/value database stored on computer network. One
Imagine the following database: Table 'companies' has fields id, name and flagship_product_id. Table 'products'
Please imagine this small database... Diagram removed dead ImageShack link - volunteer database diagram
Imagine the following problem: You have a database containing about 20,000 texts in a
Lets imagine I have the same database schema as here: http://www.databaseanswers.org/data_models/driving_school/index.htm If a customer
I'm designing my database and LINQ To SQL ASP.NET web application. Imagine I have
What is the best way to track changes in a database table? Imagine you
Imagine you want to animate some object on a WinForm. You setup a timer
Imagine the following (simplified) database layout: We have many holiday records that relate to

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.