Mysql – What should be the structure for a person-to-person store database

database-designMySQLPHP

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?

Best Answer

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.