[verb ます-stem] + ませんでした
From the dictionary form:
~ませんでした is the polite past negative of a verb: "did not". Take a verb in its ます form and change ます to ませんでした. It is the negative ません with でした added.
The two parts always come in that order: ません first, でした after it.
ませんでした says that something did not happen in a time that is over: yesterday, last week, this morning. When it has not happened yet and still may, Japanese uses まだ with the て-form and いません.
So the answer "no" to もうたべました食べましたか (have you eaten yet?) is いいえ、まだたべていません食べていません.
ませんでした goes on verbs. For a noun or a な-adjective the past negative is ではありませんでした, and an い-adjective changes its ending to くなかったです.
These go beyond the basic polite sentence.
ませんでした goes on the same ます-stem as ます: 食べる → 食べませんでした, 読む → 読みませんでした, する → しませんでした, 来る → 来ませんでした (read きませんでした).
In conversation you will also hear the plain past negative with です added: たべなかったです食べなかったです, いかなかったです行かなかったです. It means the same and is a little less formal. ませんでした is correct everywhere polite speech is.