how to “brute insert” categories into wp database?

I know it may not be a good practice but I need a way to insert a category for my post using INSERT, the problem is I cannot understand how categories and the relation with post work in the database.

I have created a script that gives me the complete SQL for inserting posts (and all the information for every post I need) without problems. But for categories seems like I need to modify 3 tables at the same time.

Does anyone can explain to me how a category is inserted and related to a post in the wp database scheme? Or any article about it will help me as well.

I have like 60k posts that need to relate to about 2k categories.

Thank you.

1 Comment
  1. WordPress has functions for creating categories and inserting posts so you don’t have to write SQL queries.

    Alternatively if you want to continue on your route, ought to give more insight in the tables and structure.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer