Complex sentence: The history of the castle stretches back to the year 870 with the construction of its first walled building, the Church of the Virgin Mary.
Split into simpler sentences: The history of the castle stretches back to the 9th century (870). The first walled building was the Church of the Virgin Mary.