RE: [PHP-DB] Unlimited Categories
Well, I'm not sure if you actually truly mean "unlimited", because if you do, be aware that when you define those fields: # BIGINTUNSIGNED = 8 Byte = = 18446744073709551615 # INT UNSIGNED = 4 Byte = = 4294967295 # MEDIUMINT UNSIGNED = 3 Byte = FF = 16777215 # SMALLINT UNSIGNED = 2 Byte = = 65535 # TINYINT UNSIGNED = 1 Byte = FF = 255 # BIGINTSIGNED = -9223372036854775808 to 9223372036854775807 # INT SIGNED = -2147483648 to 2147483647 # MEDIUMINT SIGNED = -8388608 to 8388607 # SMALLINT SIGNED = -32768 to 32767 # TINYINT SIGNED = -128 to 127 So, while an UNSIGNED BIGINT would be a bahugabyte number, it is in fact finite and not unlimited. :) > -Original Message- > From: Micah Stevens [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 13, 2003 9:45 PM > To: Gerard Samuel > Cc: php-db > Subject: Re: [PHP-DB] Unlimited Categories > > > Use the parent/child relationship thing: > > CREATE TABLE Categories ( > CategoryID int(11) NOT NULL auto_increment, > ParentID int(11) NOT NULL default '0', > Category_Name tinytext NOT NULL, > PRIMARY KEY (CategoryID) > ) TYPE=MyISAM; > > So at each level you can find the subcategories by: > > SELECT * FROM Category WHERE ParentID = $This_Level_ID; > > The top level would have a ParentID of 0. > > *shrug* - One way to do it. > > -Micah > > On Mon, 2003-01-13 at 21:32, Gerard Samuel wrote: > > > Im figuring this is more of an sql question than anything else. > > I'm trying to figure out a table structure to create > unlimited depths of > > categorical data. > > I've done something for category/subcategories before, but > haven't an > > idea how to create categories at an unlimited depth. > > > > Any pointers would be greatly appreciated. > > Thanks > > > > -- > > Gerard Samuel > > http://www.trini0.org:81/ > > http://dev.trini0.org:81/ > > -- > Raincross Technologies > Development and Consulting Services > http://www.raincross-tech.com > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Unlimited Categories
EG: CREATE TABLE category ( id int not null auto_increment, parent int default 0, name varchar 100, ); The parent field contains the ID of the record of which category it belongs. Then use a recursive function to display the 'levels' of data. (If parent is 0 then it is top level category) Luke Woollard -Original Message- From: Gerard Samuel [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 14 January 2003 4:32 PM To: php-db Subject: [PHP-DB] Unlimited Categories Im figuring this is more of an sql question than anything else. I'm trying to figure out a table structure to create unlimited depths of categorical data. I've done something for category/subcategories before, but haven't an idea how to create categories at an unlimited depth. Any pointers would be greatly appreciated. Thanks -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Unlimited Categories
Use the parent/child relationship thing: CREATE TABLE Categories ( CategoryID int(11) NOT NULL auto_increment, ParentID int(11) NOT NULL default '0', Category_Name tinytext NOT NULL, PRIMARY KEY (CategoryID) ) TYPE=MyISAM; So at each level you can find the subcategories by: SELECT * FROM Category WHERE ParentID = $This_Level_ID; The top level would have a ParentID of 0. *shrug* - One way to do it. -Micah On Mon, 2003-01-13 at 21:32, Gerard Samuel wrote: > Im figuring this is more of an sql question than anything else. > I'm trying to figure out a table structure to create unlimited depths of > categorical data. > I've done something for category/subcategories before, but haven't an > idea how to create categories at an unlimited depth. > > Any pointers would be greatly appreciated. > Thanks > > -- > Gerard Samuel > http://www.trini0.org:81/ > http://dev.trini0.org:81/ -- Raincross Technologies Development and Consulting Services http://www.raincross-tech.com
[PHP-DB] Unlimited Categories
Im figuring this is more of an sql question than anything else. I'm trying to figure out a table structure to create unlimited depths of categorical data. I've done something for category/subcategories before, but haven't an idea how to create categories at an unlimited depth. Any pointers would be greatly appreciated. Thanks -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php