List:General Discussion« Previous MessageNext Message »
From:David Blomstrom Date:August 24 2005 10:21pm
Subject:Re: Treating Two Fields Like One
View as plain text  
--- douglass_davis@stripped wrote:

---------------------------------
 
In my opinion:
 
The easiest thing for you to do right now would be  a
table like
 
ID (primary key) NAME PARENTID
 
You don't need PARENT, because you have the PARENTID,
you can always retrieve parent.   Although... i still
think it would have been simpler to do separate tables
for each taxonomic level, and this single table design
may cause problems down the road if you start adding
more fields... but anyway.
 
Keep it simple.  One ID is all you need to identify
any row.   As far as the URL, you could use the scheme
i gave earlier for the URLs (if you can absolutely
guarantee 100% every NAME-PARENT combination will be
unique), but it would be more complicated PHP code and
more complicated queries, and links would break when
spellings changed.   Just use the ID in the URL, it's
simple. 
 
If you add or delete rows, or change spelling, the
keys stay the same,  primary keys don't change.  Just
make sure you don't delete anything's parent and
everything will be just fine.

* * * * *

OK, thanks. I'll give that a try. I'll probably try to
combine it with the recursive array described at
http://www.sitepoint.com/article/hierarchical-data-database/3
(after I learn how to do it).

Let me throw one more curve ball at you, though. I now
understand that I can't combine my primary key with
the field Name, like 8leo. But do you know if I could
combine numerals from this "tree traversal" script
with Name?

Here's why numerals appeal to me. If I combine fields
like Name/Parent ID - e.g. leo/Pan, then it will be
more difficult when I want to separate them. If I
combine Name with a numeral - e.g. leo/8 - then all I
need is a script that weeds out all numerals. I think.

Does this make sense?

Thanks.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Thread
Treating Two Fields Like OneDavid Blomstrom24 Aug
  • Re: Treating Two Fields Like OneEnrique Sanchez Vela24 Aug
  • Re: Treating Two Fields Like Onedouglass_davis24 Aug
    • Re: Treating Two Fields Like OneDavid Blomstrom24 Aug
      • Re: Treating Two Fields Like Onedouglass_davis24 Aug
        • Re: Treating Two Fields Like OneDavid Blomstrom24 Aug
  • Re: Treating Two Fields Like OnePeter Brawley24 Aug
    • Re: Treating Two Fields Like OneDavid Blomstrom24 Aug
    • Re: Treating Two Fields Like OneDavid Blomstrom24 Aug
      • Re: Treating Two Fields Like OneSGreen24 Aug
        • Re: Treating Two Fields Like OneDavid Blomstrom24 Aug
      • Re: Treating Two Fields Like OnePeter Brawley24 Aug
RE: Treating Two Fields Like OneGordon Bruce24 Aug
Re: Treating Two Fields Like OneDavid Blomstrom25 Aug
  • Re: Treating Two Fields Like Onedouglass_davis25 Aug