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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:51:26+00:00 2026-05-26T02:51:26+00:00

The table I got a table that contains price for some 1 000 000

  • 0

The table

I got a table that contains price for some 1 000 000 articles. The articles got a uniques ID-number but the table contains prices from multiple stores. Thus if two stores got the same article the uniques ID will not be unique for the table.

Table Structure

table articles

id INT

price IN

store VARCHAR(40)

Daily use

Except for queries using the ID-number by users I need to run daily updates where data from csv-files insert/update each article in the table. The choosen procedure is to try to select an article and then perform either an insert or an update.

Question

With this in mind, which key should I choose?

Here are some solutions that Ive been considering:

  • FULLTEXT index of the fields isbn and store
  • Add a field with a value generated by isbn and store that is set as PRIMARY key
  • One table per store and use isbn as PRIMARY key
  • 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-26T02:51:26+00:00Added an answer on May 26, 2026 at 2:51 am

    Use a compound primary key consisting of the store ID and the article ID – that’ll give you a unique primary key for each item on a per-store basis and you don’t need a separate field for it (assuming the store id and article id are already in the table).

    Ideally you should have 3 tables… something like:

    article
    --------------------------------------------
    id | isbn | ... etc ...
    
    
    store
    --------------------------------------------
    id | description | ... etc ...
    
    
    pricelist
    --------------------------------------------
    article_id | store_id | price | ... etc ...
    

    With the PRIMARY KEY for pricelist being a compound key made up of article_id and store_id.

    EDIT : (updated to incorporate an answer from the comment)

    Even on a million rows the UPDATE should be OK (for a certain definition of OK, it might still take a little while with 1 million+ rows) since the article_id and store_id comprise the PRIMARY KEY – they’ll both be indexed.

    You’ll just need to write your query so that it’s along the lines of:

    UPDATE pricelist SET price = {$fNewPrice} 
    WHERE article_id = {$iArticleId} 
    AND store_id =` '{$sStoreId}'
    

    Though you may want to consider converting the PRIMARY KEY in the store table (store.id – and therefore also pricelist.store_id in the pricelist table) to either an unsigned INT or something like CHAR(30).

    Whilst VARCHAR is more efficient when it comes to disk space it has a couple of drawbacks:

    1: MySQL isn’t too keen on updating VARCHAR values and it can make the indexes bloat a bit so you may need to occasionally run OPTIMIZE TABLE on it (I’ve found this on an order_header table before).

    2: Any (MyISAM) table with non-fixed length fields (such as VARCHAR) will have to have a DYNAMIC row format which is slightly less efficient when it comes to querying it – there’s more information about that on this SO post: MySQL Row Format: Difference between fixed and dynamic?

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

Sidebar

Related Questions

So I've got a table that contains a number of datetime fields, and I
I've got a table that contains a LocationId field. In some cases, where a
I've got a very large table (~100Million Records) in MySQL that contains information about
So I've got a column in a table that contains a string values (keywords
I've got a table that stores the following: JobID ValidationItemID CreatedBy I want to
I've got a table that has some <input type=text> boxes in it, and I
i've got a table like that : Article Number Last Voucher Number Last Voucher
I got a child table that contains 1 to n records linked to the
I've got a CSV file that contains multiple data chunkds: Alice Age,Weight,Height 20y,50kg,170cm Bob
My problem is simple... or may be not. I've got a table that contains

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.