0

I like to develop a shopping cart website with multiple products. (ex.: mobile phone, furniture etc.,) here mobile phone specification will cover

  • size of display
  • memory
  • operating system
  • camera etc.,

but for furniture - its specification is entirely different from above electronic product.

  • type of wood
  • color
  • weight
  • shape
  • glass or mat finish etc.,

My question is: how to handle a common database-table for product specification ? each & every category of product & its spec will be differ - so how to have a common table ProductSpecificationTable ?

I searched many site including google.. but cant able to get the perfect soultion. Please help me to move to next step.

Sensa
  • 383
  • 3
  • 6
  • 20

3 Answers3

0

Ask yourself the question: How can I accomplish this kind of database? First of all you need products.. Every product has to be in some kind of category and every category has to have his own properties. So, you've to create a product table with unique id and every product needs a category id. At this moment it is time to link from your property table to your category table(by id) and to set the values you need a 'property_value' table.

**table:**         **id**
product        --> category id
property       --> category_id
property_value --> property_id

I hope you will understand my explanation otherwise just ask :)

GuyT
  • 4,316
  • 2
  • 16
  • 30
  • Hi GuyT Thanks for your valuable reply. My question is: how to handle the product specification table with unique fields for all product category ? as in my example: electronic related product is having different product specification and furniture related product is having different product specification. so, how to handle both of these product specification data in a single table "tableproductspecification" ? – Sensa Jan 17 '14 at 10:01
  • That's what I explained. Eg. Your product_id = 1(Blu-ray player), category_id = 1(eg. Electronic). Now you can add properties to your property table. eg. property_id(Harddisk volume) and category_id = 1. In your property value table you set your property_id(500GB). Get it? – GuyT Jan 17 '14 at 12:06
  • I clearly understand what you explained but my question is how to make a common property table for all products ? For product like "Mobile Phone" its property table fields will be: size of display; memory; operating system; camera etc., But, When i feed a product "TV Showcase" its property fields are differs like: color of furniture; material etc.. in this case i have to create a separate property table for each category or is it possible to have one common property table for all products irrespective of category ? – Sensa Jan 21 '14 at 04:15
  • That's what I'm trying to tell you. Create 1 common property table with an `ID` and a `category_id`. You can add properties by category. In you property value table you'll also need to add the `product_id`. So, you've a category 'Mobile Phone'(category_id = 1) and 'TV Showcase'(category_id = 2). Now you add properties to the property table with a 'property_id' and 'category_id'. In your property value table you add the values with 'prop_val_id' and 'property_id'. I can't explain it better I guess.. – GuyT Jan 21 '14 at 08:14
0

You can add 1 more table to accomplish that. Table that contains cat_id, product_id and the property. That is a many to many relationship. I believe this way you can accomplish thst.

Engel
  • 1
0

You can achieve this with a single table within a database but that will complicate the CRUD operations over the table. So I will recommend you to create one database like ‘Inventory’ which can have multiple tables (one table for each of the Product Type).

First Table could be list of Product Types you have (mobile phones, accessories, furniture):

enter image description here You can use this table to populate your list of items available. Here the column _table_name will contain the actual name of the Tables.

Then for each of the product you can have different tables with different number of columns:

Table for Product Type Mobile Phones: enter image description here

Table for Product Type Furniture: enter image description here

I hope this will help.

karn
  • 5,963
  • 3
  • 22
  • 29