+2  A: 

Your first question confuses me. UML makes me think of objects and "Posts-table" makes me think of relational databases. Which one do you mean? I'll assume that you want objects.

You need an interface or abstraction that represents both questions and answers - maybe that's the Post interface. It'll have attributes like text and author and a timestamp when it was posted.

Since the question will never come before an answer, if you have a collection of Post instances it'll be in the proper order if you sort it by timestamp.

UPDATE: UML means object-oriented programming. Python is both an object-oriented and a functional language. So that means you'll be thinking about the problem in terms of objects first.

Thinking in terms of objects means setting aside concerns about user interface and database. You design the objects to provide the kind of behavior that you need. You can have a simple text interface at first, and object serialization will do for persistence. But get the objects right first.

When you say "interface", I think of Java interfaces. They declare the signature of the class, but say nothing about implementation. So your Post interface might have Question and Answer implementations.

What contains all the Post instances? What owns them? I'd have another object called KnowledgeExchange to own the collection of Posts. Let it hide all the implementation details and provide methods to getQuestion and getAnswers. Don't force your clients to have to know all those details or even whether or not you implement it as a stack or list.

Like I said, don't worry about tables or persistence just yet. Think about objects. Best to make the whole problem in terms of objects instead of just Post, Question, and Answer.

duffymo
+1 for sorting out the confusion. I did not consider the issue farer than Python and MySQL for the project. Very interesting first paragraph. Can you explain it a bit further?
Masi
I added two interfaces updating the photo with many fixes inspired by your tips
Masi