SQL now referencing correctly on foreign keys, etc.