Fixing exception when deleting key
Adding CASCADE statements to prevent some bugs