D
D
Dmitry2014-09-08 01:27:49
PHP
Dmitry, 2014-09-08 01:27:49

How to properly store this data or how to process it correctly when requested?

There is a need to store a product specification, a kind of belonging to a particular group of products in the database. When requesting a specific page, they should show only records that have the type that was requested in the "specification" (for example, by filter). What I came up with at the moment:
for n-products, in the database, in the specification column, such an entry is "phone fablet 2core etc". The page requests products related to the "phone" specification. Request

SELECT * FROM table WHERE specification LIKE '%phone%'

How correct is this version of the request, and am I moving in the right direction in solving this kind of problem? I would be grateful for any "poking your nose" in "bad" places and directions in the right direction. Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Philipp, 2014-09-08
@another_dream

Create a separate table where your filters will be stored and a link table between products and filters. In this case, it will be easy to select similar products.
product <-> product_to_specification <-> specification
If necessary, it will be possible to classify features of specifications, show products that have the same specifications or are the most similar in terms of parameters.
If full-text search is required, then immediately look towards sphinx.

X
xmoonlight, 2014-09-08
@xmoonlight

LIKE '%phone%'so the query will be executed for a long time.. it is
necessary ( LIKE ='phone''phone%' (in extreme cases...)) prop_id), a list of tree post types link: (id, type: category, good, property, etc..), a list of prop values: (id,title,parent_id,param1,....paramN) and a link table (id, goods_id, prop_id).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question