ionic compounds form when millions of