Determine if "item" in parent table or child table

Well this is where I make a suggestion and then get my wrist slapped by Rudy shortly thereafter :stuck_out_tongue:
If it were me, i’d combine the subcategory and category tables thusly:

CREATE TABLE `categories`(
	`category_id` BIGINT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 
	`name` VARCHAR(255) NOT NULL
        `parent` BIGINT(10) UNSIGNED DEFAULT 0 
); 

If it’s a Category, parent is 0, if it’s a subcategory, parent is the ID of its parent category. Since you’ve specified a 1-level hierarchy, this would satisfy all data storage.

1 Like