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 823783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:00:01+00:00 2026-05-15T03:00:01+00:00

I want to add dynamic columns in a mysql table but I don’t know

  • 0

I want to add dynamic columns in a mysql table but I don’t know exactly how.

I want to let the user add some columns (fields) in a thread, eg. let him add a integer field and a value (eg. price: 199) or a string field and a value (eg. name: teddybear).

The user can add as many field/value-pairs as he wants.

I thought I could create a many-to-many table:

thread <-> thread_field <-> field

thread: id, title
thread_field: field_id, thread_id, value
field: id, name

is this a good structure?

But in this way I have to set a specific column type of thread_field.value. either it’s an integer or a string. I want to have the possibility to have it dynamic, let the user choose.

How can I do this?

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-05-15T03:00:01+00:00Added an answer on May 15, 2026 at 3:00 am

    This problem comes up very frequently with regards to relational databases. It’s part of the definition of a relation that it has a fixed set of attributes, not dynamic attributes.

    If you need to allow user-defined attributes in a relational database, the simplest solution is to store a Serialized BLOB such as XML or other semi-structured format (JSON, YAML). You lose the ability to query this efficiently using SQL (unless you use an RDBMS that extends SQL with XML functions and indexes), but you’re going to sacrifice many features of the RDBMS no matter how you solve this problem.

    Another alternative is to use one of the new non-relational data stores like CouchDB or MongoDB, which makes it easy to extend entities with dynamic, strucutred attributes while remaining somewhat efficient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

TLDR I want to add some dynamic content into an Ext-JS window / popup.
I want to add some dynamic content in from clause based on one particular
Hi i have a table and i want to add dynamic rows to that
How do I add dynamic libraries in iphone xcode? I want to add the
I want to add a few dynamic rows right in the middle of a
I have created a Dynamic View Panel custom control and want to add a
I have a website built with ASP.NET (3.5) and want add some level of
I want to add some jQuery functionality to our sites where one piece of
I want to add a dynamic image in the UITableView's tableHeaderView part. For that
I have creted one dynamic temp-table and dynamic query.Now I want to populate it

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.