0

I am going to create a person-to-person store with Laravel, a website whose users can share and sell their product or their mobile, TV, Computer, Shoes, Shirts, Books ,Cars, Bags, Animal etc.

I am going to create a table named Products. Other tables about product are, for example, Bugs, Animals, Cars, Shirts, Shoes or Computers.

products table:

product_id   |   cat_id     |   title    |   cost    |    timestamp

cars table:

      id     |  product_fk  |     brand   |   model   |    type    |  Fuel  | ...

Computers table:

     id     |  product_fk  |     brand   |   type     |    CPU     |  GPU    |  hard_disk  |  ...

I will create other, similar, tables.


I want to know if there is another way to do this which is better and easier?

What do you think about this structure?

  • You don't need to write your question in bold and bigger font. – vijayp Jan 21 '15 at 7:44
  • @vijayp Do you mean All the problem solved and the big problem is the Font? :) . Can you answer to this question? – kermani Jan 21 '15 at 7:51
  • Read up on Entity-Attribute-Value (EAV) designs. They are exceedingly flexible. Storing all the different product categories consistently would be simple. EAVs are very difficult to make fast at scale, however. – Michael Green Jan 21 '15 at 12:20
0

There could be many way possible to store data for such scenario, as with your design attempt it seems that you are looking to have unique Id to identify each product and if that is the case the you are right with having a productstable and make that product_id an auto increment key.

Now the next thing to make sure that what ever the attributes of all these bugs, Animals, Cars, Shirts, Shoes, Computers which are common can be added in products table, attributes related to sales can be a good choice to save in this table.

Now Let say for car you will have different brand, design, Engine(Diesel/Petrol), seats, Color and so on you may need other look up tables to save these attributes similar for all the other product like Shoes, Computers etc.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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