18 Replies
My DB looks like this
ISBN is a 13 digit code
Int stores up to 10 digit numbers
imho it makes no sense to store an ISBN as an
int
its a bit like a phonenumber, its a number, but you never use it as a number
you dont do math on it, or ordinal comparison
other than that, seems fine? your DTO is just a subset of your entity, so no complicated mapping requiredIndeed you do not do math on it... But amount of space in the int for representing an isbn seems to be insufficient? I'll double check, but what if you get a full 13 digit code where the first number is greater than 4 (to account for unsigned int)
I'd say long or string (with charmax(13)) might be better
Stack Overflow
What is the best data type for ISBN10 and ISBN13 in a MySQL database
For an application I'm currently building I need a database to store books. The schema of the books table should contain the following attributes:
id, isbn10, isbn13, title, summary
What data types
string is best suited for isbn, based on this post. Which makes sense, as int would trim, and long is longer than needed
Yeah, I would recommend strings for ISBNs, personal identity numbers, phonenumbers etc
ISBN is a collection of digits and could also contain leading zeros
another good reason for not using a numeric type🙂
I faced some problems with a POS when they stored ZipCodes as numerics and I was not able to filter out mistyped ZipCodes. 1234 could be wrong or 01234 - who knows?
Or it could be valid because it was a foreign ZipCode
Also I wouldn't use the isbn as an id for a book. Afaik a single book can have more than one isbn
So use your own incremental primary key.
You'd have to do the same for users. Using someones government id number was proved to also be an unreliable primary key
true but it's a uni project fr, i'll just make some little assumptions
alright
(not so) fun fact, these government IDs can change due to protected identities, judicial sex change etc. A friend of mine went through this and it was a nightmare in some systems, as they simply didn't support changing it on an existing customer and essentially had to create a new account and "try to migrate" the data over.
Well, at least you can see how much you need to research, even for something as simple as a book db... But I'd understand if you decide to not include these suggestions for a uni project
Government is cutting edge
Cause it's actually something a lil more complicated than this
i have to build a microservice based application
like this is just a microservice
Well, all the best with the project!
$close
Use the /close command to mark a forum thread as answered