LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-21-2011, 07:05 PM   #1
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep: Reputation: 51
ISBN-10 and ISBN-13 dashes


I'm setting up a database that will store details about some books, including the ISBN-10 and ISBN-13 numbers. I'm trying to figure out how many characters I'll need for each, exactly. Q: There are always three dashes in an ISBN-10 ID, and four dashes in an ISBN-13 ID, correct? So that would be 13 characters necessary for an ISBN-10 ID, and 17 characters necessary for an ISBN-13 ID, correct? The Wikipedia description left me a little uncertain.

I'd prefer to store them as integers instead of as text, but apparently the dashes separate semantically significant groups, and the number of digits in each group are not fixed. (grumble, grumble)
 
Old 05-21-2011, 09:23 PM   #2
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by hydraMax View Post
There are always three dashes in an ISBN-10 ID, and four dashes in an ISBN-13 ID, correct?
No. An ISBN is actually a 3 or 4-component vector with integer components and an additional single-digit checksum. The components may be separated by spaces or dashes.

Quote:
Originally Posted by hydraMax View Post
I'd prefer to store them as integers instead
Feel free to do that. Actual ISBNs are unique without the separators. They have to be, since the barcode does not contain the separators, just the numeric value. You can reconstruct the separators, but it's usually not worth the hassle.

Unfortunately, the last digit in the ISBN code may be X instead of a digit. Since it is just a checksum, it is derived from the other digits; you probably should store it separately. When searching, you can ignore the last character altogether -- Amazon does.

Note that if you store ISBNs as a vector, searching using a partial ISBN is next to impossible. Well, you can get your database to do it for you, but the cost in CPU time and memory use is not worth it at all.

Personally, I'd store ISBNs in two or three related fields:
  1. Unique integer part
    (Omitting the checksum character and separators)
  2. Optionally, the integer part as a string
  3. As a string of up to 17 characters (or more)
    (Used only for display purposes)
The first one is unique for each book. I'd use it as a key. If your DB supports binary integers, you might wish to have a copy as a string, so that you can do partial ISBN searches. The last one, the string representation, is used for output purposes only; never for searches or selection. Obviously, your frontend should derive all from the same input.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
UPC or ISBN number lookups? MrUmunhum General 2 02-28-2010 05:13 PM
Console gives dashes instead of lines rob207 Linux - General 1 10-14-2006 10:30 AM
'df -h' shows dashes instead of stats charleycat Linux - Software 1 05-02-2006 10:33 PM
Typing em dashes? culturejam Linux - General 1 12-13-2004 10:11 AM
Dashes in Grub.conf herkdrvr Linux - Newbie 2 10-12-2004 08:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration