Database: Add method to check for foreign key constraint failure

database.referenceError() takes a mysql error and returns the name of the field
which caused a reference error, if any. If the error isn't a reference error,
then `null` is returned.
Comment: Return E_INVALID_DATA for foreign key errors
App: Initialize comment module