Store a checksum for every file. You can probably use the code from any of the P2P networks, that calculate the checksum of a file to determine they are the same file, regardless of name. Add this checksum to the filestorage data modell. Every time a file get's uploaded the system automatically will check whether that file is already in the system and make a link to the version_id of the this already uploaded file if true. This, by accident, has another great benefit (besides saving diskspace on your harddrive). You see where files are used and get a network of people / classes / parties that seem to have something in common.