Multiple databases- MySQL

software development

#1

So here’s my problem: I have some news content in one table and some forum postings related to the news content in another table.

I need to set things up so that I can query and display news content and the related forum comments.

But I don’t want my forum users to be able to access the news table.

So I need to find a way to either a) put these two tables in the same database with a user scheme that allows a user to write to the forum table but read-only the news table; b) keep the tables in separate databases to control access, but write a join query to link the related forum and news items; or c) find another solution that I haven’t thought of.

Any ideas?

Thanks.


#2

I would copy the news table into the forum database, or vice-versa. Because if you start querying two databases, it would seriously hit performance I think.
Just export the news database, and insert the tables into the forum one, just make sure that no tables share the same name. Then you can query the things at the same time.
Unfortunatly,this would let anyone trying to hack your site, delete everything if they managed to do some sql injection. Using the DH panel, you can stop the MySQL user for your forum from dropping or altering your tables. I wouldn’t recommend removing delete priveledges since your forum software may need it.

(I think you can only have one database per mysql host with DH… if this is the case then the above still stands to my knowledge. If you can have more than one database per mysql host, and you have it set up that way, then you can write queries using db_name.table.field )