when creating a document, upload a file, then upload a second one before saving the update. It will create the following records:
A) A document record with content that links to attachment 2;
B) Two attachment records (with uploaded files), both with parent being the document record;th content
C) Possibly a revision record with content that links to attachment 2.
The document deletion process looks at the content of document and the load directory irevision records and deletes the corresponding attachments and their files.
For the scenario described, this means that attachment 1 record is not deleted.
When the document record is deleted, the orphan Attachment record has its parent set to Zero. This makes it visible in the Media screen. The file will be available (and possibly deleted) if the Upload directory is iused to store documents, but if another directory is used, there will be in WordPress way to delete the file.