Answer the question
In order to leave comments, you need to log in
How to store product data in the database?
There are solutions for storing product data in this form:
product (id, name)
param (id, name)
product_param (product_id, param_id, value)
But the question is the data type for the value field. You can Text, but it seems to me too much. is there any decomposition of this option? Or is it not worth it at all? there is little information on the Internet about this issue
Answer the question
In order to leave comments, you need to log in
In the param table, set the data type of this parameter, and in the product_param table, the entire set of data fields that will be needed to describe any parameter. There can be not only types that are standard for the database, but also for the subject area (intervals, dimensions, etc.).
param (id, type_data /*parameter data type or dimension (it is better to take dimension as another property)*/, name)
product_param (product_id, param_id,
value_int -- integer
value_int2 -- integer for integer interval types (from value_int to value_int2 )
value_str -- string
value_date -- date
value_date2 -- date for date range types (from value_date to value_date2)
)
Usually they do this:
product
-------------------------------------------------
id
name
price
weight
....
meta - json type or text
tags
id
name
productId
productTags
id
tagId
productId
Everything that is common is placed in the product table.
tags are already assigned for greater detail, you can also enter categories so that each category of goods has only its own set of tags
. And finally, non-functional is rendered in json,
for example, links to manuals, and so on. All this field is already processed by your logic in the application
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question