It works even though I recreated those tables with appropriate foreign keys. So it looks that when you load the data model from SQL scripts when installing or after dump it won't work, while manual recreation of the above does. Strange.