I'm not sure what you meant by the database comment, since both of my blogs are referring to SharePoint, but SharePoint _is_ a database. Why can you not do a field check from the "db," which is just the SharePoint form library? You can definitely create a data connection to receive data from your form library in order to check if that Document ID already exists. If it does, then pop up an error saying so and don't let the submit continue. Sounds really simple to me, but maybe I'm missing something?
You keep referring to a Document ID, but you make it sound like that is the filename. This document ID you're talking about comes from the original Word doc, right? That is not the same thing as the InfoPath filename in the form library unless you are choosing to submit the forms using that Word document ID as the filename. I would not make that the filename, or at least I would not rely on the filename to do my primary key check. Create a field in the form that gets promoted to the form library that contains the Document ID. In your submit button, check to see if the current form's Doc ID is already in the library. The conditional statement would look like this:
If Any Occurrence of SharePointList:DocID is equal to ThisForm:DocID, then display message saying whatever. If Not, then submit.