Who Built the Berlin Wall?

There are two theories on why the Berlin wall was built. Some say to keep the US, French and British troops from invading. Another theory says it was the Soviet Unions way to keep their people from fleeing.