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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:43:03+00:00 2026-06-06T03:43:03+00:00

First, I wish to apologize if the title is vague, the question is hard

  • 0

First, I wish to apologize if the title is vague, the question is hard to summarize – please feel free to edit as appropriate.

In a website I am building, I have products within categories (and the categories are being expanded constantly) that have attributes (I can’t think of a better word, I apologize for the fact that this crosses with database terminology, but I mean attribute as in color, size, weight, not as in a field of a database table). Those attributes may or may not be defined depending on the category, and sometimes specifically the product.

Now, individuals using the website will want to create a query that searches for items matching specific attributes (think “is green, weighs less than 4 lbs., rated 3 stars or higher”), and save that query in the database as a tuple of a table that they can reference. Mind that these will be end-users, so they will not be able to actually write the query themselves. Also note that there may be a great deal of redundancy in some types of queries, and that there will be many more of these queries than there are items.


My first thought:

Store the items all in one table (items), with an id, category id, name. Store attributes types in attribute_types with id, name, type (which would be int, string, enum, etc). Store attributes in a separate table with item_id, attribute_type_id, and value.

Then, create the query based on HTML selections as though I were actually querying the database, save the exact query, and store it as a string in a table with an id and query. Check for the existence of a query before storing it.


This seems as though it would work, but I can’t immagine that this is the best way to go about it. Is there a more efficient, or frankly less ugly, solution? Am I even storing the items in an appropriate manner?

Thank you,
James

  • 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-06T03:43:05+00:00Added an answer on June 6, 2026 at 3:43 am

    If the number of specific attributes and categories is small enough, this is usually solved using Concrete Table Inheritance (or some other derivation of it), if not you need an Entity-Attribute-Value model – which is difficult to do complex queries with and, in the long run, can lead to GIGO pretty fast.

    Magento DB Schema

    Another alternative approach is to use schemaless datastores, such as MongoDB or serialized blobs.

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

Sidebar

Related Questions

First of all, I apologize as I feel I should be able to find
I wish to show users of my website a pop-up alert on their first
Desired Workflow First I wish to fetch a particular set of questions and answers
I wish to capitalize the first letter of a sentence, on-the-fly, as the user
I wish to know how Old Linux scheduling algorithm SJF (shortest job first) calculates
I'm using constructor injection for the first time and wish to write my code
I wish to extract just the first 1024 bytes of a stored blob and
(First of all I don't speak english as well as I wish, I hope
First, I wish to write myself a generic type for operations against the underlying
I wish to have two threads. The first thread1 occasionally calls the following pseudo

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.