The best approach to make a report based in dynamic data

I have an Asp.Net MVC application where I need to create a report.
This report will show some data about an entity (activities), but only activities of ONE specific type that will be inserted in the database (until now).

My data model is:

Activity:

Int ID
DateTime Date
Int TypeId

Activity Type:

Int ID
String TypeName

As activity type doesn’t exist yet, how would one implement this report?

I thought about adding one property to Activity Type:

Bool IsXYZ //(hypothetic name here)

And then render my report showing only activities where the type have “IsXYZ==true”.

But I really don’t know if this is the best approach to do this.

I tried to search about how to do this, but I don’t know how this is called (or even if this has a name).

1

Assuming ID is the PK of each table, and that there is a FK in ACTIVITY_TYPE pointing to ACTIVITY (typeid --> id)

  • User selects an activity type from a dropdown list (by name)
  • Dropwodn list returns ID of selected activity type
  • This query is run (substituting 999 with the ID of the activity type user selected):


        select a.id,a.date,t.typename
        from
            activity a join activity_type t 
            on (a.typeid=t.id)
        where
            a.typeid = 999;
    

  • If no rows are returned, inform that to the user or draw/print an empty report.

  • If rows are returned, show/print the report.

After some research, I ended up with the following solution:

I added a new “key” property in my “Activity Type” entity.

And in the report, I will filter data from my db by looking for a specific “key” value.

Later, the user can configure which Activity type they want to see in the report just by editing this key value.
For example:

  • The report will look in the database for activities whose type has
    a specific key, let’s say “XYZ”.
  • The user then just needs to edit the activity types that they want to be
    shown in the report by adding this key value.

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *