Use foreign keys correctly in inherited tables