Hi. For the most part, the connection between ammonia and pH isn't of much concern for the aquarist. If i'm not mistaken, there is some connection between pH and the toxicity of the ammonia. For example, the ammonia is more or less toxic dependent on whether the pH is high or low. I am not completely positive on this however as it's been a while since i read what i am trying to quote. Ammonia comes from fish respiration, waste, and rotten food/ plant matter as i'm sure you know. The pH of the water is determined by the where the water comes from. The porous rock deep in the ground where the water is located determines the pH of the water. Carbonic acid does build up when the water is in a confined space to lower the pH some, but again, i wouldn't worry too much about that either. pH and alkalinity are difficult subjects to explain, and i don't fully understand them myself. The best thing to do is to try to keep the pH of your tank (whatever it is) as stable as possible. Let the good bacteria take care of the ammonia, and perform water changes if the ammonia gets too high (in an uncycled tank).
Good luck, hope this helped some.