Field contains foreign IDs for different tables
- by Rich
I am developing a php/mysql driven facebook game. I am stuck on an element the table design. When a user completes a task I want to trigger any number of events.
I was thinking of something like so:
tbl_events
*event_id - serogate primary ID
*task_id - foreign ID of the task just completed
*event_type - what type of event e.g is it a facebook stream publish or a message to the user or does it unlock a new element of the game?
*event_param - this is where it gets tricky...
the event parameter is a problem for two reasons,
1) it will contain different foreign ids... dependent on the event_type and thus it will not be possible to join to x table. Meaning I would have to call two queries.
2) Most events require a single id or text, however some events require multiple parameters - like the facebook stream publish.