ruby on rails - Tables for Orders -
i'm having difficult time setting model/table relationships hobby project i'm working on. have order, order have 1 or many packages, each package has 1 or many products, each product have 1 area assigned to. there can multiple of same product on order , in same package each have different area , different quantity. i'm struggling determine how relationships set up.
at end of day need run report shows me order details listing packages on order , products , areas contained in each package. need report shows me order , sum of quantities each product on order (no packages on one). i'm using rails activerecord think believe there couple polymorphic relationships, i'm struggling identify them outside of simple "everything has one-to-many relationship" thinking. =)
can please me put these tables in intelligent manner? have searched similar schema diagrams without success , i've been working on couple of days , starting run together.
this basics of thinking of relationships, i'm not sure rails models like. seems every relationship orders down polymorphic.(?) how nest these relationships in rails?
i'm learning , many things, seems simple becomes lot more complicated when start writing code it. on right track? help.
i think need join tables.
an order
can have many products
; product
can added many orders
.
in case you'd have join table have 2 columns: primary keys order
, product
. 2 composite primary key.
i don't know area
means in schema, perhaps suggestion break mental logjam you.
Comments
Post a Comment