views:

56

answers:

1

I am trying to create a table to hold user actions on my web app. Take a simple case where a user adds a new story, and comments on it. This will add two entries to the user_action table. In the user_action table I would like to store the module name associated with each action and the items id. In this cause I would store the modules as News, and Comment (and the ids of the two items in the modules). Is something like this possible:

SELECT * FROM user_action JOIN user_action.module m ON m.id==user_action.item_id 
WHERE user_action.user_id = 1 

Thanks

+1  A: 

What you want are polymorphic models. Read SQLAlchemy docs about this topic or Google them.

iElectric