add IsValid method, fix get foreign key name