You can probably achieve the same by using the Shared groups in Openfire (check the group settings). Inserting directly into database is not a recommended way of doing this. Also, you have mentioned, that you don’t like that users can manually add contacts. Well, you haven’t ruled that out. They should still be ale to search and add users. You can try blocking this with Packet Filter plugin.
The problem with “Shared groups” is that I have to handle manually the groups. But I did in my system a way to automatically create users and groups in the OpenFire server, without end user interference.