complex sql query approach

Hi All,

I have a question about what would be the best or the “rails” way to generate a report from my web app that is basically a web store. I wonder if I should just come up with a complex sql query by hand (which would probably take a while to figure out since I don’t know much beyond basic sql, i.e. haven’t delved into joins yet). Or should I just use my rails models and attributes and do all the calculations in ruby (I fear this could this could entail a significant database hit).

Here is my data structure.

Artists has_many Releases has_many Products has_many LineItems has_many Orders.

I would like to generate a sales report that lists each artist with their associated releases and for each product associated with that release I would like to list the number of copies sold and the total sales price.

Any opinions on the best way to approach this?

Thanks in advance,
Sean

Hi All,

I have a question about what would be the best or the "rails" way to
generate a report from my web app that is basically a web store. I
wonder if I should just come up with a complex sql query by hand
(which would probably take a while to figure out since I don't know
much beyond basic sql, i.e. haven't delved into joins yet). Or should
I just use my rails models and attributes and do all the calculations
in ruby (I fear this could this could entail a significant database
hit).

Here is my data structure.

Artists has_many Releases has_many Products has_many LineItems
has_many Orders.

I would like to generate a sales report that lists each artist with
their associated releases and for each product associated with that
release I would like to list the number of copies sold and the total
sales price.

Any opinions on the best way to approach this?