Is Ultegra 9 speed compatible with Sora 9 speed?
Yes, and Yes. Brifters will work fine and the cassettes will work fine. You can use any 9 speed Shimano road components in the drivetrain (crankset+chainrings with appropriate bb, chain, cassette, derailleurs) and the rear derailleur can be a &lt;10 speed mountain derailleur as well. The chain can be made by KMC/SRAM/Shimano/etc. and the cassette can be Shimano/SRAM as well. I'd also run new cables+cable housing in the process as well, obviously.

In fact, the shift from Ultegra to Sora in this case might make the bike feel even better (contrary to PeteH's comments). This is due to trickle-down -- the features of old Tiagra/105/etc. have slowly moved down to the lower levels, so you get the good ergonomics and stuff of new Sora. 

As for a general thing, I'd probably just get any 9 speed Shimano/SRAM cassette in the future which has the spacing you like, as well as a SRAM/KMC chain for 9 speed (these come with quick links which are less annoying than the inane Shimano rivet). I don't see the point in scoping out for Ultegra-grade parts for this bike unless it makes you feel good -- just a waste of money given the past 16 years of engineering, since people will be hawking them at higher prices for people who just have to have the complete set. A Sora grade chain will be fine, though.