HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /A shop gives every product a code: the letter P followed by a fixed number of digits, such as P0427…
HardComputer ScienceHigh School (9–10)Computer Science › Databases and SQLNumericalIGCSE

A shop gives every product a code: the letter P followed by a fixed number of digits, such as P0427…

StemPy LabContributed by StemPy Lab

Try it on paper first. A hint, the key idea and the worked solution are here when you need them.

A shop gives every product a code: the letter P followed by a fixed number of digits, such as P0427. The shop sells 430043004300 products now and expects to sell three times as many in a few years. Every product must have its own code, because the code is the primary key.

  1. How many products must the codes cover?
  1. What is the smallest number of digits that gives enough codes?
  1. How many different codes do those digits give?

Check your answer

Work it out on paper, then type your number. The answer itself stays hidden.

Need a reminder? The key ideaShowHide

The six basic data types are text (alphanumeric), character, Boolean, integer, real and date/time. Choose a type from what the values look like and what you will do with them. A primary key is a field whose value is unique in every record and never empty, so it identifies exactly one record.

The worked solution

Have you tried it?

Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.

Given. 430043004300 products now, three times as many later. Codes are P and then ddd digits.

Step 1. Products to cover. 3×4300=129003 \times 4300 = 129003×4300=12900 products.

Step 2. Try 4 digits. 104=1000010^4 = 10000104=10000 codes. That is fewer than 129001290012900, so two products would have to share a code. Not enough.

Step 3. Try 5 digits. 105=10000010^5 = 100000105=100000 codes. That is more than 129001290012900. So 555 digits are needed.

Check. A primary key must be unique, so the number of codes must be at least the number of products.

Answer: (a) 129001290012900 products. (b) 555 digits. (c) 100000100000100000 codes.

Log in to save this for later
← All Problems
← A garden centre stores its plants in this table…A student designs a table of club members and stores the phone number 07700 900814 in a field Phone… →
More onComputer Science › Databases and SQL

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Data types and the primary keyDatabase Tables, Data Types and Primary Keys

More on this topic

  1. A restaurant stores its staff in a table Staff…Hard
  2. A town library stores its readers in a table Readers…Medium
  3. A gym stores its members in a table Gym…Easy
  4. A school garden club records each plot in a table Plots: the water it needs each day in litres, its…
Hard
  • A school weather station stores one record a day in a table Weather: the rainfall in millimetres…Medium
  • All problems on this topic →