Jump to content

Recommended Posts

Hi all,

 

I have a small question about which way would be the best to  set-up the following. Say i have a Job board and one is allowed to give a few keywords related to the post with for instance a maximum of 5 keywords.

what would be the best way to store these words in a database.

 

1) should i add an extra column tot the table comments and put in the keywords for instance comma separated and explode() them when needed. ie:

#table comments:| comment_id |   comment   | title   | author| category_id | posted  |  keywords

 

2) should I make an extra table with keywords and maybe even an extra table to link keywords to comments?

ie:

#table keywords:| keyword_id | keyword

extra table:

#table keys_per_comment: | kpc_id | keyword_id | comment_id

 

The first method is easiest for me i think, but I am not sure which one would be fastest or better for scalability reason. if anyone has tips or ideas, or a better way i would love to hear it since i never really worked with these kind of relationships.

ty ::)

Link to comment
https://forums.phpfreaks.com/topic/223245-keywords-what-would-be-the-wisest-setup/
Share on other sites

I would definitely go with the 2nd option (an association table).

That way you would be able to pull the applicable rows with one single mysql query (job board table JOIN keyword table) rather than querying the job board table, pulling all rows and then reading keywords in PHP.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.