As many other people have indicated it depends on intellectual property clause in your employment contract or the intellectual property agreement that you signed at the beginning of your employment.
There are companies that make you sign over the rights of anything that you develop during your employment over to them whether on company time or not. There are even companies that claim ownership of future inventions in the area in which you work. When choosing an employer you should choose carefully if you want to pursue things on your own time.
In general many agreements (such as mine) cover works developed on company time, as well as related work. So if you work on databases at work and you come up with a database invention on your own time your employer may have claim to your work based on it being related to your job function.
However the law is fuzzy. I recommend retaining an attorney that specializes in intellectual property and has another partner that specializes in employment contracts. Patents are expensive and you should be willing to shell out some serious cash...because after all your patent is original, awesome and world changing. In any case your employer can always sue you saying that you violated your employment contract, whether you actually did or not.
No right answers. But when looking for your lawyer look for one with good references.