What is the difference between sunscreen and foundation?

Sunscreen is used to protect our skin from harmful UV radiation while this foundation resembles cosmetics. There is also a spf 30 PA++ feature to protect the skin on the face.