Here is a story of how a guy who murdered his mother and has (obviously) a record of mental illness can still purchase firearms. With his nasty past, he is not entered into any database that could cause him to fail a background check. The problem starts with state laws not working.
http://www.startribune.com/local/west/187610601.html?page=1&c=y
http://www.startribune.com/local/west/187610601.html?page=1&c=y