All buildings in a city have to be connected to each other, you can only place a new building next to an existing one. The only exception to this are the buildings placed on resources, they can be built as long as the resource is within a city's sphere of influence.
There is also a limit to the number of building slots a city can use, it is set to 50 slots. Resource buildings do not use up any of the building slots... but only as long as they are not next to one of your other city buildings. As soon as you build any standard city building like a house next to a resource building, it is added to the city itself and takes up 4 building slots for no additional benefit.
An iron mine provides 1 metal/turn if it's out "in the wild" and provides the same 1 metal if it is joined to the city by another building, except now it also eats into your precious building slots. I freed up 20 slots in my capital by tearing down resource buildings, then tearing down the buildings connecting them to the rest of the city, rebuilding the city buildings in spots away from the resources and finally rebuilding the resource buildings. Of course now my capital looks like a complete mess.
So yeah, I'm not happy with the current system. I'd much prefer it if the resource buildings never used city slots, at least I could build nice-looking cities then without shooting myself in the foot.