We have an e-commerce site (web application) built with PHP.

There are different types of products like mobiles, tshirts, watches, books.

  • A mobile can have attributes like, for example, ram, model name, os.
  • A t-shirt can have attributes like, for instance, color, size.

My questions are the following:

  1. Is it better to save all attributes in a single table called Products (even if there will be/it will create a lot of 'NULL' marks)?

  2. Save different types of products in different tables like Mobiles, Tshirts, etc.?

In the second case, more tables will be created, see the two images below:

Diagram 1

Diagram 2

As suggested via comments, I am using the EAV model, so I drew the following design [ image 3 ] :

enter image description here

as suggested in answer, instead of eav , i combined all 3 tables in one table as product_information + attributes_list + attributes_values = products information i drew all in one table [image 4 ]:

enter image description here

Please suggest me is i need to go with image 3 or image 4 ?


1 Answer 1


What you can also do, is following. You create a table with three columns: product_id, property and value. So you get not more tables then neccessary. But it's a matter of taste.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.