R
R
RobQwerty2021-02-05 16:55:35
Database design
RobQwerty, 2021-02-05 16:55:35

How to organize a database with dynamic characteristics?

Greetings!
There are goods with different characteristics in the online store, for example: if these are mobile phones, then the characteristics are as follows (standard: GSM, camera: 20mpx, infrared port: yes, well, etc.), and if it is a refrigerator, the characteristics will be as follows (Type of refrigerator: Two-chamber, Number of compressors: 1, Type of control: Electronic, etc.)
So the question is, how to organize a database using Mysql and Laravel? Does each product type require its own table?
Or use JSON fields? What is safer and faster? Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BasiC2k, 2021-02-05
@BasiC2k

From the experience of implementing a similar project: A
separate table is created for all products with the fields:
- [Property ID]
- [Product ID]
- [Property short name] - For example, "Memory capacity"
- [Property value] - For example, "30"
- [Unit dimensions] - For example "GB"
- [Property type] - for grouping properties according to some internal features.
Accordingly, each product can have an infinite number of properties.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question