The chemical reactions and pathways involving nitrates, inorganic or organic salts and esters of nitric acid.