Domain Model - Thanawas-Sirilertsathit/ku-polls GitHub Wiki

Iteration 1 Domain Model

Domain Model The diagram shows the relationship of Question model that contains question_text and pub_date. In the same time, the Choice model contains choice_text and vote. Moreover, the Question and Choice has a relationship of association which can be implemented in one to many or many to one direction.

Iteration 2 Domain Model

Domain Model

This diagram added one more attribute for Question which is end_date because we implemented end_date in this iteration.

Iteration 3 and Iteration 4 Domain Model

Domain Model

We count the number of votes for a specific choice by counting through the built-in vote_set that is inverse direction from Vote --> Choice.

def votes(self):
    """Return the votes of the choice"""
    return self.vote_set.count()

Since iteration 4 doesn't change any models, we can use the same domain model as iteration 3