For those who have no experience, these codes are usually classificatory and each character means something specific, a grouping, a way to use, it is as if they were tags. It may seem but they are not random, they may even expose sensitive information in some cases, so they do not serve security.
If there is the unique identifier generated by the bank, why should I have a custom one?
That would have to be asked for who did it, right? It must be a requirement of the system.
It may be that all these codes have been used all their lives and it would make no sense to change what everyone is used to because of the database.
It may be that the code used there has a specific semantics that helps identify what the item is, so it is better for people to manipulate than a ID
DB sequence. So it’s a matter of UX.
It could be legislation or regulation or industry-wide common practice.
It’s almost never about safety, it doesn’t make sense to be, because it’s not about security. If someone needs to make use of this to have security in the system then everything is lost. This is called obscurity security and is known to be problematic. If you have another security measure do this does not change anything, if you do not have is insecure. If they have done so, and only those who have done so can answer, tremble with fear.
It is very easy to circumvent the assembled code and not sequentially after someone has seen some. Any code should not give insecure access in any way. Every system shall be prepared for secure normal access in forms not foreseen in the system and prevent unsafe access. And note that the code is classificatory, not a long and almost random code, as the UUID is (which has its problems, but it’s another matter). You need a good mechanism of authentication and authorisation that controls security, then the code is irrelevant to it. Basic rule: data coming from outside is insecure by nature, this includes the codes received.
If the sequential code is sensitive, this one that has a qualification can be more sensitive still and deliver relevant information, not that it matters.
I didn’t even get into the question that maybe this code is only for internal applications, because the question doesn’t make that clear. But do not fall for this security in any case. I repeat, it is 99% certain that it is not security, the 1% is wrong use of trying to provide security. Vulnerability will be to think that the code gives some security, the "invader" knows that not, and counts with this ingenuity of who made the system. Insecurity always occurs due to ignorance/ingenuity of the developer.
There is another question that can be asked: why not use this code as the primary key?
I have answered in Values that can be entered as primary key. In short, this code may not be stable, so it’s not a good candidate.
What are the best practices or rules for generating such code?
I’m glad you asked why. Too bad this is a case I can only speculate.
Good practice is a crutch for those who do not want to learn real motivation. Understanding the workings of that in all its details gives you allowances for making the right decisions instead of adopting something that someone has already adopted for her case, without considering its context, so you fall for that bullshit. Good practice may have been created because you don’t understand the subject. I know a lot of the wrong things they do around being alleged as good practices because people don’t understand the context, copy without assessing the real need. It may even be that it was good practice decades ago, but it doesn’t make sense today, but everyone keeps doing it.
If you search here about the use of primary key has enough information (I myself answered several) to understand what may or may not be used in this way and why the primary key must be stable.
Now, regarding the code used by the company to identify the product is not something that should be decided by the developer, for this person what is worth is the id
database. This secondary code is for people to adopt, it’s to improve the user experience, and it should be decided by the people who are involved in the business process, it’s not technology. It is common in some organizations to have a committee to decide these codes so important that it is.
Just make sure it can be accessed easily, have a secondary index to find quickly.
In general when you have this type of code should not be exposed the ID
table, but has exceptions.
You need to see if its creation should be validated in any way, if there is a clear rule that can be confronted with other input data.
I’m not saying I know what’s best for this case, just giving some idea to think.
"Good practice" is to use when you have a real reason for it. An example among several reasons to use custom formats (just to get away from what has already been posted): car plate in Brazil, which is a "unique identifier" were letters + 4 digits so that anyone could memorize when seeing to be able to annotate later. Nothing would prevent it from being a sequential numbering only, but it would be a pain in the ass to control it, besides losing the ease of memorization. Note: Too bad who wanted to do this crazy board Mercosul (full of problems) does not understand these basic things.
– Bacco