How to store product specifications table in database

In product detail page, I want to display a table of specifications with two column and many rows. I could do it easily by storing the specs in JSON file, but I guess it will not be the best way as all data should be stored in the database. As I have like 100 products already put in a table of products in database, so if I want to store specs table it means that I will have to create 100 more table, each table is for one products in the database. I thought it would not be the best solutions, so how can I solve this problem. Please notice that each specs table will have different number of rows and information. My JSON object containing product_specs is like below:

      "111": {

        "product_specs": [
            {"header":"Brand", "data": "Dell"}, 
            {"header":"Model", "data": "XPS"},
            {"header":"Origin", "data": "USA"},
            {"header":"Production year", "data": "2022"}
        ]
    },
    "119": {
        "product_specs": [
            {"header":"Manufacturer", "data": "Acer"}, 
            {"header":"Series", "data": "A"},
            {"header":"Purpose", "data": "Learning"},
            {"header":"Warranty", "data": "2 years"},
            {"header":"Gifts", "data": "X watch"}
        ]
    }

My desired table in detail page: enter image description here

Research for hours, still stuck.

Upvotes: 0

Views: 28

Answers (0)

Related Questions