Added enforcing foreign key referencing thanks to percyperez.