Microsoft
Software
Hardware
Network
Question : Storing catagories and sub categories in a database
Hi,
Im planning a website which will contain lots of items all in different categories. I know how to store different categories all with their own unique ID. But im trying to work out how to store the sub categories so I can tell which ones belong to which category. If the sub categories have their own unique ID there will be nothing saying which category they are in. So all I can think of is, if I have a category ID of 1, having sub category ID's of 1.1, 1.2, 1.3 and so on.
Look at this example. If I had a category called "PC Components" with an ID of "22". Inside that there is "Graphics Cards" with and ID of "22.1". Then inside that there are "AGP 8x" with an ID of "22.1.1" and "PCI Express" with an ID of "22.1.2".
(22) PC Components
(22.1) Graphics Cards
(22.1.1) AGP 8x
(22.1.2) PCI Express
As far as im aware no number fields will accept more than one decimal point. So the only way I can see to do this is to use a string to store the ID's and then split the string to obtain the seperate ID's. However, I cant remember if your able to set a string as a primary key field.
So my question is how can I do this?
(Just encase it affects anything, I will be using PHP with MySQL)
Thanks in advance
mms_master
Answer : Storing catagories and sub categories in a database
Try to have 3 basic fields:
1. Id
2. ParentID
3. Decription
You can create any "tree" using this schema
Any item can have as many sub-items as you like and all of them will have unique ID withing the same parent, etc....
Random Solutions
minimums Files to boot a custom small Win Xp system
a potential security concern has been identified
Using ASPStateTempSessions table to store Web Sessions
Setting up Internet Authentication Service with Mac addresses
Sharing Multiple My Calenders in Outlook 2003
In Outlook 2007 is there a way to customize the calendar so that the birthdays that are in the contacts don't show up on the candar?
How do I split an url to get the file-name
I need to get a list of all exchange users with statistics
Countdown Graphic
Need to change root password on production server.. help!