Gosh, "sonata" is probably the most nebulous term for a western musical format there is!
Well, ok. You could say, in a nutshell, that a sonata most basically represents the harmonic movement from the tonic (original key) to the dominant (the 5th tone of the key), and then back to the tonic/original. LOL.
If you were going to learn about what a sonata is, I would recommend to you, or anyone, that the one to study is the form developed in the classical/romantic era. Especially you, since you like Beethoven, and are learning about Haydn.
Basically, you'll have two thematic ideas. (Think about that 4-note opening theme of Beethoven's 5th, for instance. A bit later, you'll have the second theme, which is often quite contrasting in nature, and this case is no exception with the more light-hearted, lilting second theme.) The philosophical idea is that these two themes affect each other, create a thematic/musical contrast. Art imitates life. As the music develops, changes, you hear these themes again at the end, in what is called the recapitulation. It is here that the themes have lived their adult lives, are matured, and are heard in the perfect sense. When you did hear the very opening, those themes can be thought of, I suppose, as young brazen adults. The music in between is their journey through life together, and the end is the mature result. It is very likely that when a composer during this area wrote such a piece, that the original/inspirational idea is in fact located at the end of the work.
EDIT: I should say the matured themes are at the end of the movement, not the "work". Just didn't want to confuse anybody!