Add check for existence of foreign keys
Signed-off-by: JohnMave126 <johnmave126@gmail.com>