user report generation by various attributes
User table contains the following attributes (dateOfBirth, race, gender, ...). We would like to generate a report in the following format.
Year Race All Male Female 2000 Asian 2000 1000 1000 2000 Hispanic 1000 500 500 2001 Asian 1500 700 800 2001 Hispanic开发者_StackOverflow中文版 1300 400 900 ...Ideally I would like to view different reports filtered by the above parameters (e.g. All Asian Male users in year 2000, All Asian users b/w years 2000-2005, All Hispanic community in 2001). What would be the best way to fetch this data, as I would like to avoid too many hits to the database to construct this data. What framework would be ideal in fetching / representing this dataTotal 5800 2600 3200
You can have a look at Jasper Reports:
http://www.docstoc.com/docs/2139263/Jasper-Report-Tutorial
or
http://www.javaworld.com/javaworld/jw-09-2002/jw-0920-opensourceprofile.html
It's a smart framework to generate reports.
You didn't give any details about the database back end you will be using, but in general the most efficient way to generate this information will be to process the data aggregation and filtering on the database side with the correct SQL and pass only the result set to your report generator. For the first example, which appears to be an aggregation of all of the data in the table, the database engine will have to sort and process all of the rows, but you'll be better off doing it there instead of the client. For queries involving subsets of the data, make sure you're indexed correctly for your queries.
精彩评论