I downloaded the category and categorylinks table sql.gz files from mediawiki and generated the required tables:
category and categorylinks
Manual for the ta
Categories alone have no hierachy. It’s the category pages that make the subcategorization work. So you will also have to get the page_id from the page table to be able to resolve this relation.
It essentially works like this:
cat_title is a page title.page_title in the page table, get the page_idpage_id to get the category link in cl_fromcl_to