It seems that you want to distinguish between categories and topics in two separate tables, but there are identifiers for both of them in another table likesto make it easier for users to like a category or topic.
What you can do is create a super-entity table with categoriesand subtypes topics. A key with auto-increments will be generated in the super-entity table and inserted into only one of the two subtype tables (depending on whether it is a category or topic).
Subtype tables reference this super entity through an automatically increasing field in a 1: 1 ratio.
, - likes ( ), id .
, :

, , superentity.
- . , , categories topics title url: superentity, . , .