Sorry for the uninformative title, I do not know how to name this operation. Here's an example that I hope will help.
We have users, for which we log events. Events can be of different types. We want to generate a report (a new table) that will say if an event as occured for an user; for example:
Events x EventInfo = UserEvent
--- --- ---
UserId | EventId EventId | Type UserId | login | verify
------------------ ----------------- ------------------------
1 | 1 1 | login 1 | True | True
1 | 2 2 | verify 2 | False | False
2 | 3 3 | login
Additional constraints:
- We do not know the event types beforehand (neither their name or the number of distinct types)
- Has to happen entirely in the database