tags:

views:

19

answers:

1

Hi, I have a table which maintains categories from another site.

I populate this table with the data i fetch from other site as xml.

The data are divided as categories and products.

Some products does not have a category and the category xml does not have the others category.

So what i thought was to add a category others and setting its primary auto increment ID field to -1. So while inserting values into products table for all the entries which dosent have a category i am setting to -1.

The auto increment initial values is 1.

Is this a good practice. will it be valid or will it be a problem sometimes later for some conditions(any)?

The db operations are working well but i want to know if it could be a problem later.

+1  A: 

option one (my preference) - allow in products table categoryid == NULL. This is clearly shown non-categorized products.

option two - create default category and assign product to this category if product category not specified

Michael Pakhantsov
That is nice. I will follow the second option. The first one ... i never dealt with NULL values.Besides, what do you think of my way ... i think it is a overhead... because i am creating a row manually and setting its id to be -1... what do you say?
Jayapal Chandran