Depression and insomnia go hand in hand. While it may be a common assumption that depressed people sleep a lot, in at least as many cases of depression a significant lack of sleep is noted. As a result, chronic insomnia is often a symptom of deeper rooted depressive disorders, and when looking into causes for insomnia, doctors will often closely examine a patients current state of mind. If depression is successfully diagnosed, in many instances insomnia will be the result of that depression.
This is why, in some cases, when people seek out a doctor to help with insomnia they are prescribed an SSRI tablet as a treatment option. In cases of chronic insomnia coupled with depression, it is very common to be provided with a short term dose of popular sleep medications as well as the longer term SSRI meds. This is done because an SSRI takes time, sometimes up to 2 weeks to be effective at inhibiting seratonin re-absorption. A sleeping pill is used to allow for proper rest until the SSRI is up to speed in your system. I'll get into that a little more later on, but if you were treated for insomnia with a prescription sleeping med as well as an SSRI such as Prozac, e.t.c... don't panic, your doctor knows what he's on about.
Depression is normally treated with the ever popular Paxil, Zoloft, Prozac, e.t.c... which are all SSRI derivatives (Selective Seratonin Reuptake Inhibitors). As I eluded, these medications work to stop Seratonin from being reabsorbed back into the nerve cells of your brain. It useful to know what seratonin is, for the purpose of understanding how suh a deficiency can cause insomnia.