English 中文(简体)
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 1300 400 900
...

Total 5800 2600 3200

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 data
最佳回答

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.

问题回答




相关问题
How to model a many-to-many relationship in App Engine?

I have a question regarding how to model a many-to-many relationship in App Engine: A Blogentry can have many tags, a tag can apply to many blog entries. I see a couple of scenarios: Use a Set of ...

How to emulate tagged union in a database?

What is the best way to emulate Tagged union in databases? I m talking about something like this: create table t1 { vehicle_id INTEGER NOT NULL REFERENCES car(id) OR motor(id) -- not valid ... } ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

How to best implement a 1:1 relationship in a RDBMS?

Yesterday while working on a project I came up on a peculiar 1:1 relationship which left me wondering - how to best implement this (clearly, we had done it wrong :D) The idea is that there are two ...

Automatic filling entity properties

I have some type an architect(?) question I develop an application, based on Spring and Hibernate (annotated configuration) For each table in my database I added 4 fields: createdBy and modifiedBy(...

热门标签