As the link points out, you create a composite primary or unique key on both of the properties. If both are used for the primary key, than you cannot insert 2 records with the same documentID and classID, but you can insert as many records of documentID and classID together that create a unique entity.
You can do nothing to prevent duplicates being entered if you don't know about the entries before hand (and in languages like PHP that is typically not ideal to move around with that much data at a time). Instead, you let the language accept whatever is given to it, and then you attempt to provide it to the database. It will throw an error if you attempt to insert a duplicate, and you can simply relay back saying its not unique.
You can use AJAX if you want to detect this while they fill in the form. The logic is identical to one that were to check for a unique username, but you would give it both fields to work with instead. I know for sure you'll be able to find a script on google for an ajax username check.