On Sat, 15 Mar 2014 08:38:03 -0700 (PDT), willy Hakizimana
<willyha24@gmail.com> declaimed the following:
>First of all, this community is amazing at how fast questions are answered.
>I have learned so much.
>
>
>I am designing an app with models that look like this.
>
>Country(country_id(PK), country_name, gdp, gdp_growth, income_per_capita)
>
>Product(product_id(PK), product_name, country_id(FK), imports_volume)
>
>Since I have to show imports_volume for the same product in each country, I
>am stumped on how to design the db.
>
If I understand your statement, you need (paraphrased) the
imports_volume to be for each product for each country...
That means it does NOT belong in either Country or Product tables.
Country(*countryID*, Name, gdp, gdp_growth, per_capita_income)
Product(*productID*, Name)
Imports(_countryID_, _productID_, import_volume)
In Django terms (I believe), this is a many2many relationship using a
via table (the native m2m would create a table with _countryID_,
_productID_ foreign keys only; the via table lets you add data specific to
the relationship itself... An intersect table in older database
terminology)
>
>
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5g19i9h4hp2bscr4ep4o47fhcbsgm4akth%404ax.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment