Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

integer id column. need to add data

how to link

categories to products

I have a products table
with an integer id column


product 1 could be
category: electronics

product 2
category: electronics > audio > audio components
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Care to post the schema (CREATE TABLE) for both tables?
Avatar of rgb192

ASKER

I need to create categories table


products table is integer for productID which is primary key
ASKER CERTIFIED SOLUTION
Avatar of sachitjain
sachitjain
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

why is category.categoryid
not
autoincrement
You could keep it autoincrement but since it has to be a self referential foreign key so you would need to take care when you enter ParentCategoryId of other rows in this table. Like suppose CategoryId of Electronics is 1 and that of Audio is 2 comes out through autoincrement then you would have to ensure that ParentCategoryId of Audio is kept as 1 and that of Audio Components is kept as 2 and so on to maintain the hierarchy.
I need to create categories table

products table is integer for productID which is primary key

I am afraid that tells me nothing, so I am glad you got some help.

Good luck.
Avatar of rgb192

ASKER

thanks

i will leave no increment now