When I first started working on a payroll system at a previous engagement, I was very frustrated with the biggest problem in building payroll systems: Handling time. That is - the change of things and values over time.
You see, in a payroll system, you need to know not only what "Dan"'s salary is Today, or what it was on January, you also need to know what you "knew" about Dan's Salary regarding January when you created the payroll for February (assuming today is March, for example). You actually need to keep tabs on time in two dimensions: The actual time, and the history of the actual time. (I always think of it like a comet and it's tail - the comet being the place in time you want to know about and the tail - the value in that time's history you want to know about).
Were you just able to wrap your head around that last paragraph? because you can just imagine how much problem solving you need to do with such a system - data wise, architecture wise and design wise.
I won't go into the excruciating details (for now), but if you're in the same bind as I was then, you'd appreciate knowing that Marting Fowler has a nice writeup on various patterns for "Temporal Data" - data which changes in time, which try to solve exactly these problems. I wasn't aware of many of these back then and, as usual for cases where you invent the wheel - came up with my own half-assed solution. Reading these I found that I was on the right track in some places and off track in others (in a way).
On a related note, "Patterns of Enterprise Application Architecture" is by far one of the most eye opening pattern books I've read (along with the classic Gof book). The great news is Fowler is on his way to making more of the same good thing - continuing on with a different book. Meanwhile we can all enjoy his thoughts on the patterns he comes up with online on his bliki. I consider it a treasure trove of things to think about - like a totally free book of open thoughts.
Most of it is pure gold - stuff you really wanted someone to put in words for you.
What can I say? This guy is going somewhere ;-)