I have the following sql view result which contains the audited changes for every field for every table in the system:

In this case the above image tell us that both read and write permissions were revoked for the user Lucas for the subscription called MySubscription.
I need to display that info in a grid however that is not what I want to display, I mean, I don´t want to display IDs. I need to display “Read” instead of 50, “Write” instead of 51, “Lucas” instead of 1 and “MySubscription” instead of 6.
To do that I would like to improve the sql view to get the values instead of their IDs as I mention above. The result that I am looking for is this one:

The database contains the tables Subscriptions, ProductPermissions and TenantUsers to get the needed info using joins.
Could you please give me some clues about how could I achieve what I need? Thank you.
You could do this with a series of
LEFT JOINs, some casting might be required to get the datatype of the joining column the same asNewValue(I’ve assumed a column calledNamein all your joining tables, this may need changing):If required you could then PIVOT this into one row per transaction:
It is a pretty dirty solution, I would be inclined to store this data in the format you want to select it in i.e. instead of 50/51, store read/write directly in the
NewValuecolumn.Alternatively, if you did want the second format with one row per transaction then I’d be inclined to store it in this way. It could be worth reading about the Entity-Attribute-Value Antipattern.