On 08/21/2011 03:25 AM, Christian Ramsey wrote:
> Hi and thank you so much,  this provided a ton of clarity, especially
> the modelling of the order table with a foreign key to a user, I was
> locked on thinking the user table needed to somehow have the orders
> within it. But I see I needed to step back.
> 
> I've already started to implement all of this and I am trying to
> understand the  additional table, if the Order table already contains
> the user it belongs to, then what will the additional table be set
> for, from my perspective would this be to keep the original order?
> 
>>
>> I never implemented a shopping application and  what I suggest is very
>> probably neither the most elegant nor the most efficient solution.
>> But what is clear is, that you should use at least one table more.
>>
>> Example Suggestion:
>>
>> User: contains info about the user
>>
>> Product: info about a product and it's price (though price might be in a
>> separate table)
>>
>> Order: Info about the order, which could be ForeignKey to a user, the
>> order date, and perhaps payment status.
>>
>> And one table more, which would store one entry of a order:
>> it would store a oeign Key to a Product, the selected amount and a
>> ForeignKey to the order it belongs to.
>>

My suggestion was, that the Order just contains the customer, the order
date, and all other data, that is unique for one order,
but not the items, that have been ordered. tey would be stored in the
4th table.

So the 4th table could be called OrderItem.

each order item would contain
- to which order it belongs to (Freign key)
- what product has been ordered ( foreign key)
- how many items of the product has been ordered.

So basically a customer command cosists of all OrderItems belonging to
one Order.

As I said before there's many solutions, this is just one.



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to