SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2005
    Location
    Hagley Worcestershire Uk
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ideas and concept needed on array or database design to power thesaurus

    Hello everyone

    I want to build a Thesaurus (on beekeeping.) A Thesaurus shows the relationships between terms and starts with a top term (TT) which will be beekeeping ... STAY AWAKE! And see http://instruct.uwo.ca/gplis/677/thesaur/main08.htm for some idea what terms a Thesaurus uses.

    Now I originally built the Thesaurus years ago using HTML and each page had links to other pages some 500 pages in all and it was a nightmare to maintain.

    Now I have a working knowledge in PHP I want to build the Thesaurus using includes for the HTML header etc etc; and would like to design an engine that assembled the pages on the fly from a table or array or database.

    Has anyone travelled this way before? Can you guide me? I favour a massive array that will branch out like the roots of a tree giving the term and the branches, are there penalties in this approach such as array restrictions (size wise,) maintenance, navigation, or something I havenít though about? Or is a database better?

    Thanks

    Nick

  2. #2
    I ♥ PHP
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using a database it should be pretty easy to do this.

    First create a table of words:
    Code:
    tblWords
     id (primary key, auto increment)
     word
     description
    Now create a relationship table:
    Code:
    tblRelationship
     id (primary key, auto increment)
     wordID (foreign key -> tblWords.id)
     linkedWordID (foreign key -> tblWords.id)
    Now when you create your page you can use the following query:
    PHP Code:
    $sql "SELECT tblWords.word FROM tblWords JOIN tblRelationship ON tblWords.id = tblRelationship.wordID WHERE tblRelationship.wordID = " $wordID ";"
    This will return all linked words and you can simply output them to an HTML list and style them accordingly.

    Hope that helps.

    Regards,
    Jordan

    PS. All of the above is pseudocode only and may not necessarily be the correct syntax, it is to be used as a guide only.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •