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

PHP Server Side Scripting Forum

Best way to do search word structure?
php, mysql, search words

 8:39 am on Nov 6, 2013 (gmt 0)

I want to build up a database where there will be about 400 strings. I want to make the database searchable.

The structure of the database will be like:
Brand | model |additional products | price | search words | (this is 1 string, there will about 400 strings)

There will be between 2 and 50 search words on each string. The search are done by clicking a checkbox and the marked checkboxes words will be searched for in the database.

My question is how is the best way to index all the search words?
I’m thinking of 2 ways:

In the field | search words |all searchable words will be displayed like: 1GB RAM, 512GB RAM, ATA, SATA… and so on for each string. This means that ALL words will be in the same raw on a specific string separated by “,”.

Each search word will have its own row like: | search words 1| search words 2| search words 3 | search 4 words 5|….. and so on. In |search words 1| the word 1GB RAM will be. In | search words 2| the word 512GB RAM will be and so on… This means in a string maybe half the search words row will be filled with a search word.

In option 2 there will be more than 50 raw in the database and all search words in different column (1 in each column for each product). In option 1 there will be 1 raw with all words in the same column for each product.

Or is there a better way to do this?



 9:22 am on Nov 7, 2013 (gmt 0)

When I first started reading your question I thought you were stating the format of a "flat file" database, and how best to search this data? However, having reading your question I'm not entirely sure what you are asking... Are you using a "relational" database and wondering how you might store this data?

Are these 50 "search words" fixed in your system?


 9:32 am on Nov 7, 2013 (gmt 0)

Yes, I would like some info on what way its best to save the date in a MySQL database. All search Words will be fixed in the system - Means I will add the Words to each string.


 11:09 am on Nov 7, 2013 (gmt 0)

My first thought is to have a table (many to one) of:
KeywordId | RecordId

And a keyword table:
KeywordId | Keyword

RecordId is the primary key of your product(?) table.


 3:07 pm on Nov 8, 2013 (gmt 0)

perhaps a full text search [dev.mysql.com] is what you look for.

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