Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8364127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:21:27+00:00 2026-06-09T12:21:27+00:00

I need to store this relation: domain -> tag1, tag2, tag3 …. tagN to

  • 0

I need to store this relation:

domain -> tag1, tag2, tag3 .... tagN

to a msql table.

I figured I would just have two fields like this

domain | tag_arary

Actual data might be:

facebook.com | [social, networking, web, foo1, foo2 ]

Or another way, would be to set a maximum amount of tags and just have a field for each tag:

Structure

domain | tag1 | tag2 | tag3 

Actual Data

facebook.com | social | networking | web | foo1 | foo2 

What is the best way to implement this.

Make note, I’ll need to add tags, and remove tags.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:21:28+00:00Added an answer on June 9, 2026 at 12:21 pm

    This is probably the most flexible way for the long run, as it’s much easier to query/update/delete the tags. You might want to give id to the domains table though, as it would be much faster in terms of searching on integer field.

    CREATE TABLE domains (
     domain VARCHAR(255) PRIMARY KEY
    );
    
    # table to store all your domain names
    INSERT INTO domains (domain) VALUES ('www.facebook.com');
    
    # table to store all the tags you want to have for your application
    CREATE TABLE tags (
    id INTEGER AUTO_INCREMENT PRIMARY KEY,
    tag_name VARCHAR(255)
    );
    
    INSERT INTO tags (tag_name) VALUES ('social');
    INSERT INTO tags (tag_name) VALUES ('networking');
    
    # Then, you can store all the tags related to a domain in domain_tags table
    # It provides one-to-many relationship between a domain and tags.
    CREATE TABLE domain_tags (
        domain VARCHAR(255),
        tag_id INTEGER
    );
    
    INSERT INTO domain_tags (domain, tag_id) VALUES ('www.facebook.com', 1);
    INSERT INTO domain_tags (domain, tag_id) VALUES ('www.facebook.com',2);
    
    # Whenever you want to get the tags for a domain, simply join the tables together
    # and query based on your domain name.
    SELECT tag_name
    FROM domains d
    INNER JOIN domain_tags dt ON d.domain= dt.domain
    INNER JOIN tags t ON t.id= dt.tag_id
    WHERE d.domain='www.facebook.com';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to store this object into the internal storage memory of the phone,
I need store just 10 arrays in my app, which I can change from
I need to store a customer 's currently selected payment info ,so that this
I have a scenario like this: I need to pass @id to the stored
I need to compare two dictionary values if the types stored are equal, this
User Story: Action for Facebook that has open graph object. For this I need
Ok, I need something like this: datediff(second, date_one, date_two) < 1 dates are stored
I have id values for products that I need store. Right now they are
I need to store a very large amount of instances of my class, and
I need to store a login session when the user is login and remove

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.