Though aquariums are not true ecosystems, knowing a little about marine ecology can often help an aquarist conceptualize what's going on in their reef tanks.
Basically, you can think of an aquarium as an ecosystem with broken or unbalanced cycles that you, the aquarist, have to "patch up" and/or keep balanced. For example, in a true marine ecosystem in nature, the stages of the nitrogen cycle can remain balanced and perpetual without any help or need for interference. But in our aquariums, ammonia, nitrites, nitrates and/or other nutrients at different stages of different cycles can build up, throwing the whole system off balance. Almost everything we do to maintain our tanks is in some way mimmicing or replacing some force or fact of nature.
Food Chains
Hopefully, we all remember what a food chains are. Small things eat smaller things which are eaten by bigger things and we're all eaten by sharks, right? Well, more or less (and usually minus the sharks), the same thing goes on in a reef tank. No matter how long you stare at your aquariums, you'll never see the majority of the tiny lives that call your tanks home. Bacteria, micro-algae, microscopic benthic (sand-dwelling) critters, copepods, flatworms, etc. etc. They're all there, in the sand, on the rocks and glass, in and on your pumps, filters, corals and fish. They're everywhere. The vast majority of them are harmless if not beneficial to your reef tank "ecosystem." They eat each other and are eaten by your fish and corals. You can start to see the beginnings of a food chain already. However, like most the chains and cycles in your tanks, your food chains will also be imperfect and insufficient. You will need to feed your fish and corals more than what's "naturally" available to them in your tank. You may even want to feed all those little critters too. Figuring out what and how much to feed your tanks is inevitably going to be a process of trial and error and is truly an imperfect science. For more information on feeding, see Feeding Your Tanks
The Nitrogen Cycle
The nitrogen cycle, as a part of the greater marine ecosystem, is far more complicated than even most advanced aquarists will ever understand. By the time it comes to the minds of most aquarists, it has been greatly over-simplified down to a linear process by which ammonia (from fish, food and fecal waste) is converted to nitrites, which are converted to nitrates, which are converted to nitrogen gas or otherwise removed from the environment (taken up by algae and other organisms). This concept of the nitrogen cycle is not incorrect, it's simply stripped down. The processes by which nitrogen cycles through an ecosystem are far more complex. In aquariums, the process mostly stops at conversion to nitrates. However, ever tank is different. It's thought that in tanks with deep sand beds, more nitrogen gas is produced while in other tanks, more nitrates are produced. However, like most thoughts on reef tank ecology, this is just an intelligent guess. The complex processes of the nitrogen cycle are not completely understood even in the natural environment. So you can imagine just how poorly they're understood in aquariums. The truth is that no one completely (or even mostly) understands what goes on in any one reef tank "ecosystem." All we really know is that there are bacteria and other organisms in our tanks that convert ammonia to nitrites, nitrites to nitrates and possibly nitrates to nitrogen gas. And we know that algal growth takes up these nutrients. We're happy about this because ammonia, nitrites and nitrates are all posionous to varying degrees to different organisms. Ammonia is the most universally and potently toxic. Nitrites are toxic to all reef inhabitants at high enough levels and nitrates are toxic to more sensitive critters at higher levels. When there are not enough bacteria and other organisms to process all the ammonia, nitrites, and nitrates produced by and/or added to our tanks (i.e. food), we have to act to set things right. Depending on what stage of the process appears "out of wack" and just how bad the problem is, we can do water changes, feed less, add filters, protein skimmers, etc. If we're really desperate and in an emergency, we might even add chemical solutions claiming to help remove the toxic ammonia, nitrites and/or nitrates. Sometimes a lack of "balance" in a reef tank can be merely a symptom of its youth. Young tanks, tanks less than a year old, can be quite unstable and subject to somewhat unpredictable swings in nutrient levels and organism populations. Even older tanks can sometimes respond dramatically to an increase in feeding levels or addition of new livestock.
Photosynthesis and Gas Exchange
In our tanks, algae and photosynthentic corals photosynthesize (complete the process of photosynthesis). But they're not the only ones. Dinoflagellates, many ornamental clams, and other organisms also photosynthesize. Photosynthesis consumes carbon dioxide and produces oxygen. This is important to our aquarium "ecosystems" for a couple of reasons. 1) Your respiring organisms need oxygen and 2) dissolved carbon dioxide effects tank pH (It creates carbonic acid, raising the acidity of the water. See Chemistry: Practical Basics). Yet again, as it happens in our tanks, the system can be imperfect. Carbon dioxide can build up, dangerously lowering tank pH. Oxygen levels can become depleted, threatening to suffocate our respiring tank inhabitants. And just to confuse things, some of your organisms will do one thing during the day and another at night. Just how much these processes cause fluctuations in tank pH and oxygen levels over the course of the day will be something you'll want to try to come to understand for your tank system.
The Sun, the Moon and Stars
Unfortunately, there are many things that effect a natural marine environment that we aquarists can't easily (if at all) replicate in our aquariums. For example, the sun is not always directly over us. It rises and sets at angles that change as the day does on. Most of us only have one main light hanging directly over our tanks for 10-12 hours a day. This is something like having it be noon all day over our little reefs. Also, the effect of the moon on corals and other reef inhabitants is only beginning to be understood by professional marine ecologists. Even if the effect of the gravitational pull of the moon on natural reefs is ever completely understood, it's hard to imagine how an aquarist could ever possibly replicate such a thing in an aquarium. In the end, we may just have to accept the fact that our tanks will never be perfect. All we can do is keep ourselves informed and do our best to make our guests feel at home in the modest accommodations we provide for them.