added ajax.php functions, corrected foreign keys in database