The dissolved salts in the water used for brewing affect the flavour of the finished beer. So much so that areas of the world historically famous for certain beers as thus because of the chemistry of naturally occuring water there. For example Czech Pilsner is brewed with the very soft water found locally to the town of Pilsen. The same beer brewed in Munich with harder water produces the subtly different Bavarian style pils. The water in the area around Dortmund contains a high sulphate level which accentuates bitterness from hops, producing different again Dortmunder lagers.
Calcium (Ca) and magnesium (Mg) ions are needed by yeast to keep it healthy. Along with carbonate (CO3) ions they create water hardness. Carbonate raises the pH of the water, making it more alkaline.
Sulphate (SO4) ions can taste bitter in high concentrations and emphasise the hop bitterness in beer.
Iron (Fe), even in very low concentrations, creates a metallic off-flavour in the finished beer. Despite persistant rumour, stout does not contain high levels of iron or it would taste horrid.
Sodium (Na) can give a salty flavour and Chloride (Cl) is supposed to give a fuller bodied mouthfeel to the beer.
Beer is acidic and has a pH of around 4. If the pH is lowered it creates a more sour, acidic flavour and if raised then a soapy metallic flavour can be tasted.
Burton on Trent has a very high total salt content in its natural waters, but dominating these salts are sulphates leading to the development of drink known simply as bitter.
Dublin has very alkaline water and brewers used darker, more acidic malts to bring the end product down to the desired pH. This led to darker beers such as stouts being more common.
Pilsen has a very low total salt content in its water leading to softer tasting more subtle beer like pilsener.
Dortmund has more hardness and sulphate producing more bitter lagers.