http://johnny.chadda.se/2007/04/15/mail ... and-dspam/
This is a good tutorial to follow, especially if you want to get under the hood. It was written for Debian Etch, which is ancient now, but can be applied to all of the newer systems that are out there. I followed that guide, because I wanted to learn as well, and was able to install it back when CentOS 5.0 was released. I also installed it on a FreeBSD system. You just have to dig around in some man pages, and do some googling, but you will be able to have a functioning mail server by using this as a template. Plus, it makes you learn, and not just copy and paste code.
You can forget about the postgrey and the dspam part. He has been saying that he was going to write a how-to for those for the past two years.
To answer Void's question of what the benefit of using a database for a mail server -- it makes keeping track of multiple mailboxes and multiple domains a lot easier. Two, if you are using encryption, it adds an extra layer of security. Of course, now you can just run something like ISPCofig and forget all about this, but it is still a good way to learn the basics, and the inner-workings.