如何将对象插入多个类别并使用php检索

I have a table having root categories like:

fruit
vehicle
goods

and sub categories like:

fruit   => sweet
        => sour
        => mixed

vehicle => car
        => light vehicle
        => hatch back
        => sedan

goods   => furniture
        => wooden
        => home accessories

I want to insert a object into database using multiple subcategory of a root category

mango  => fruit(root)   => sour, mixed
maruti => vehicle(root) => car, light vehicle, hatch back
table  => goods(root)   => furniture, wooden, home accessories

In my html I have multiple checkbox list of a root category, so how can I insert this into my database and retrieve it in php? and my database structure is

parentid  cat_id title
0             1   fruit
0             2    vehicle
0             3    goods
1             4    sour
1             5    sweet
1             6    mixed
2             7    sedan
2             8     hatchback
2             9     car

and so on