it is supposed to work that way.
category and sub category names are defined in the category and subcategory tables.
in the product table, you want to store the category and sub category ID.
you return the associated name by using a join query.
for more details on join queries, see the following page: