Pergunta

I am feeling stuck while working on two different enterprise applications .

From the first Application A1 and second Application A2, we used to send some documents to our print vendor which prints those files for us .

But the document ID for each document(sent to print vendor) is the database primaryKey ID .

For example : Application A1:
Table name = FILE_RECORDS

ID | FILE_NAME

102 file1.txt
103 file2.txt
104 file3.txt

Application A2:
Table name = FILE_RECORDS

ID | FILE_NAME

104 file5.txt
105 file6.txt
106 file7.txt

Now if file3.txt from first database and file5.txt from second database are going to the same FTP dropbox of print vendor then it is creating confusion. Because both have same document ID = 104 .

Print vendor wants unique ID for each document .

How can we overcome this problem ?

Foi útil?

Solução

Prepend the unique key with the unique application id.

A1_102 file1.txt
A1_103 file2.txt
A1_104 file3.txt 

and

A2_104 file5.txt
A2_105 file6.txt
A2_106 file7.txt 

Each application produces a unique stream of document ids. The DB will only generate the number part, but you can prepend the application ID in the SQL statement:

SELECT Concat('A1_',file_num), filename FROM files;

You can do the same thing numerically by having one application start at a very high number, like 2,000,000,000. A third choice is to have one application produce even numbers (multiply by two) and the other odd numbers (multiple by 2 and add 1).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top