'postgessql : switch between tables by table id

I have 3 tables : user_rule where I would like to store user_id and rule_id. And 2 other tables with different structures (rule_table_1 and rule_table_2).

I want to store only rule_id in user_rule table and set up additional field: table_id which will define where rule is stored (rule_table_1 or rule_table_2).

Is such architecture OK? Probably there is alternative solution, so my question is about your best practice.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source