part of the Pirates problem is they don't make long term investements in players like Jason Bay, and they ship them off. This is a rare case for the Pirates.
Small market teams can compete in MLB, but just like everyone else, you have to do it right. That means drafting wisely and investing in your farm system, international scouting and developing players and it also means making shrewd decsions on players that can help you out, but won't break the bank.
There are numerous examples of small market teams having success in MLB every year- the Rays, the Brewers, and the Twins, and A's are all good examples.