On Thu, 2006-03-09 at 17:20 -0800, Gavin wrote:
> thanks for the reply, let me modify your example.
> 
> class Account(Model):
>    owner = CharField()
> 
> class Reimburse(Model):
>     price = FloatField()
>     count = IntegerField()
>     account = ForeignKey(Account)
>     expenditure = ForeignKey(Expenditure) # diff
> 
> class Expenditure(Model):
>     cost = FloatField()
>     account = ForeignKey(Account)
> 
> the only diff is Reimburse now has a field called expenditure.
> 
> so how would the creation code work now?

One concern I have had with your question is *why* you want to make this
a foreign key? Since expenditure is duplicating information that is
already available, it is slightly bad database practice to include it in
there (your model is not in any "normal form" in the nomenclature).

Is there some reason you need a foreign key here, rather than just a
separate value? After all, if you were doing this as a pure database
problem (rather than through Django), it would be recommended that you
never store expenditure, but just compute it from the raw values when
needed (which is pretty fast, since it involves a join on one field).

Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to