We have determined the O/H and N/O of a sample of 122751 SFGs from the DR7 of the SDSS. For all these galaxies we have also determined their morphology and their SFH using the code STARLIGHT. The comparison of the chemical abundance with the SFH allows us to describe the chemical evolution in the nearby universe (z < 0.25) in a manner which is consistent with the formation of their stellar populations and morphologies. A 45% of the SFGs in our sample show an excess of abundance in nitrogen relative to their metallicity. We also find this excess to be accompanied by a deficiency of oxygen, which suggests that this could be the result of effective starburst winds. However, we find no difference in the mode of star formation of the nitrogen rich and nitrogen poor SFGs. Our analysis suggests they all form their stars through a succession of bursts of star formation extended over a few Gyr period. What produces the chemical differences between these galaxies seems therefore to be the intensity of the bursts: the galaxies with an excess of nitrogen are those that are presently experiencing more intense bursts, or have experienced more intense bursts in their past. We also find evidence relating the chemical evolution process to the formation of the galaxies: the galaxies with an excess of nitrogen are more massive, have more massive bulges and earlier morphologies than those showing no excess. As a possible explanation we propose that the lost of metals consistent with starburst winds took place during the formation of the galaxies, when their potential wells were still building up, and consequently were weaker than today, making starburst winds more efficient and independent of the final mass of the galaxies. In good agreement with this interpretation, we also find evidence consistent with downsizing, according to which the more massive SFGs formed before the less massive ones.