Whew - I found it. Here's the query for forums-portlet:
and ff.package_id in
(select pep.element_id
from
portal_pages pp, dotlrn_communities dc, portal_element_parameters pep, portal_element_map pem
where community_id = :community_id
and pem.name = 'forums_portlet'
and pp.portal_id = dc.portal_id
and pp.page_id = pem.page_id
and pem.element_id = pep.element_id
and pep.key='package_id')
Alas, above query is wrong. So how can I retrieve the package_id parameteter. Here's another query that also looks promising - but is faulty as well:
select pem.element_id
from portal_element_map pem,
portal_pages pp, portal_datasources pd,
portal_element_parameters pep
where pp.portal_id = 2536537 --:portal_id
and pem.datasource_id = pd.datasource_id
and pem.page_id = pp.page_id
and pem.element_id = pep.element_id
and pd.name = 'forums_portlet';