The Shang Dynasty ruled China during the second millennium BCE. The Shang kings ruled through a complex government hierarchy and were responsible for maintaining proper relations with spirits and ancestors. Shang society was highly stratified, with a large gap between the royal/noble class and common farmers. The economy supported this social structure through agriculture. The Shang made advances in science, developing a calendar system and recording celestial phenomena. They excelled in bronze-working, pottery, jade carving, and other crafts. The Shang also developed a mature system of Chinese characters that formed one of the world's earliest writing systems.