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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:14:56+00:00 2026-05-19T03:14:56+00:00

I want to create a field in my database which will be easy to

  • 0

I want to create a field in my database which will be easy to query.

I think if I give a bit of background this will make more sense. My table has listings shown on my website. I run a program which looks at the listings a decides whether to hide them from being shown on the site. I also hide listings manually for various reasons.

I want to store these reasons in a field, so more than one reason could be made for hiding.

So I need some form of logic to determine which reasons have been used.

Can anyone offer me any guidance on what will be future-proof aka new reasons and what will be quick and easy to query upon ?

  • 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-19T03:14:57+00:00Added an answer on May 19, 2026 at 3:14 am

    If you want to allow a user (for example, yourself 🙂 ) to come up with their own reason, add a varchar(255) nullable field to your table to store the reason, and then query your table your table using where hide_reason is null or something.

    If you want a fixed number of reasons that you can change occasionally by changing the table definition, use an ENUM field: http://dev.mysql.com/doc/refman/5.0/en/enum.html. (I don’t know which database you’re using, so I’ll use my favorite one)

    If you want a fixed number of reasons that you can change with not too much effort, and that you can show in a dropdown list for your users to choose from, @davogotland’s solution really is the best. Adding a table is not that excessive in a database environment 😉

    In any case, you could always choose to use a separate is_hidden field alongside your hide_reason field, for clarity, or because you want to remember the reason someone hid a field also when they unhide it again, or whatever. If you do, use a BIT / boolean / TINYINT field for this.

    EDIT:

    Ah, wait. I misread the answer above. You want a fixed set of reasons, and you want each listing to be able to have more than one reason. This means you are in a many-to-many situation (each listing can have more than one reason, and each reason can be assigned to more than one listing). There are 3 ways to do this that I am aware of:

    1. The way you outlined above. Use “bits”, or powers of 2. Great.
    2. Use a SET data type, which is like an ENUM but with the possibility of having more than one value in it. see: http://dev.mysql.com/doc/refman/5.0/en/set.html. If you are using MS Access, there is a “Lookup Wizard” datatype which seems to do something similar (and supposedly includes an actual lookup wizard).
    3. Use a link table, linking the listings to the reasons. You will need 2 new tables, reasons and listings_reasons, which look like this:

    reasons:

    reason_id
    reason_text
    

    listings_reasons:

    listing_id
    reason_id
    

    Now, fill your reasons table with possible reasons, and link them to the listings using the listings_reasons table. This is the most common solution, since it allows you to add possible reasons without modifying your database structure.

    Good luck!

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

Sidebar

Related Questions

I want to create one insert function in php, which I will use to
I need to create an array which will give me the following json encoded
I am trying to query a string (TEXT field in the database) and want
I want to create a new field (or two) in my table that is
I want to manually create a ID field where I do MAX + 1,
I want to create a horizontal scrolling field at the top of a UITableView
I want to create a onscreen keyboard such that when a text field gets
I want to create an event content type with one field Dates contains a
I want to create a widget like Stack Overflow Tag Field. How to add
In my class, I have field int count . I want to create a

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.