By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Database design


New Coder
I would like to save the website keywords in a database so that i can create a tag cloud function.
How should I design the database? Which tables should I create?

Thank you
Assuming you have a database table for your posts, I would think you would want this structure:

  • posts table - Stores your posts, each post has a unique id
  • tags table - Stores your tags. Each tag has an id, slug and name
  • post_tags table - Each row has an id, post id and tag id
When you make a new tag, add it to the tags table. When you assign a tag to a post, you add an entry to post_tags with the post id and tag id. Then you can set up post_tags so that the post ID and tag ID are foreign keys to the posts and tags table respectively.

This setup lets you quickly query to see how many posts a given tag is used for as well as which tags belong to a specific post.
Top Bottom