mysql - Database design: Best Way to store heterogeneous subtypes of a parent class? -
website has products different categories (phones, tablets, washing machines, ... etc)
each product have diff. prices depending on store (if user views galaxy s4 16gb show $x xstore , $y ystore)
the website have heavy filtration. instance phones might filtered according price, color, .. etc. filtered manufactures or stores. (all samsung products, products @ xstore, ... etc)
for reason specs of each category should stored separately (phones: screensize, memory, os, ... etc. watches have different spec ..).
each category (phones or watches) expected have ~1000+ product.
question:
i first thought of pyramid-like design. 1 table products adding general table each category common specifications (for phones have screen-size, os, ..), third table variations (memory:16gb or 32gb, price @ each store, ... etc).
problem is: main table products large (thousands), , heavy filtrations have go , forth between 3 tables @ least, , if i'm filtering samsung products, have deal more table (tablets, laptops, ... etc). i'm not sure whether go performance point of view.
so thought of straight forward way; creating 1 single table each category. variations duplicated (galaxy s4 16gb , 32gb 2 rows , 16gb price @ xstore , ystore in 2rows). know violates normalisation. table can barely exceed 1000 rows way, i'll end having simpler code, , think performance efficient don't need index. case need deal tables when i'm filtering manufacturer i'll 've grab samsung tablets, phones, etc..
sorry elaborating, trying make clear possible don't have schemas. patience appreciated , i'm open new suggestions.
thanks in advance :)
edit
the questions categorization (only 1 level phones, tablets, ..etc) each in separate table vs in 1 table , subs category , diff attributes or specs. it's performance question.
category sub category can single table parent child relation have many sub levels
or list category in 1 table , table specify relation
id category parent 1 samsung 0 2 note 1 3 apple 0 4 ipad 3
store sperate table products table category id foreign key pricing table product id , store id foreign keys
just brief idea !!
Comments
Post a Comment