Fixed database and added constraints