Car Dealer

Hello guys. I would like a basic explanation on how to create a NPC Car Dealer (i’m doing this to learn, not for a server etc). I would prefer if you did not hand the code to me on a plate as I will not learn that way. I was thinking of using TDM Cars and linking it up with MySQL/SQLite. I think I know how to create the Derma menu’s for buying the cars etc, but linking it up to MySQL and displaying the cars a player owns in another Derma Tab is beyond me.