homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Making thesaurus list out of syntax
I Will Make It

5+ Year Member

Msg#: 4225172 posted 11:01 pm on Nov 1, 2010 (gmt 0)

Hi there!

I would like to create a database over synonyms, by splitting up a special article-syntax I have.

Example of how my article syntax is:

{main word|synonym1|synonym2|synonym3} {main word2|synonym1|synomym2|synonym3|synonym4}
... and so on.

I want to put "main words" in to the DB as the main words, and then attach the related synonyms to that word,

Can anyone give me a direction on how to accomplish this?



WebmasterWorld Senior Member 5+ Year Member

Msg#: 4225172 posted 4:11 pm on Nov 2, 2010 (gmt 0)

I would expect many to many relationships among the various words, so a synonym of one word maybe a synonym of another word and then the words themselves can be synonyms to other words.

So I would build 2 db tables one to hold each word/synonym along with an identifier and another to assign relationships.

id word(varchar)
id with an autoincrement attribute

id1(int) id2(int)
where id1 and id2 are identifiers in table-1

Then setup a couple of rules when setting up table-2 so there id1 != id2 and combinations of id1/id2 are unique.

Then retrieve the rows for the synonym for a given word by getting the id from table 1 for a given word and then picking up the ids from table-2. You could perhaps apply a limit to the query to bring up just a number of synonyms.

You could also add an order field to the second table if you know the priority of combinations.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved