[英]need advice on mysql data base design
I need to build application where users can search/filter products by multiple characteristics. 我需要构建应用程序,用户可以通过多种特征搜索/过滤产品。 There are 25 product groups.
有25个产品组。 Each product group have around 10 product characteristics.
每个产品组都有大约10个产品特征。 I have a few data base design solutions, but none of them seems appropriate enough:
我有一些数据库设计解决方案,但它们似乎都不够合适:
I believe there are already solutions for problems like mine. 我相信已经解决了像我这样的问题。 Thanks for help.
感谢帮助。
EDIT: 编辑:
In most cases the characteristics in groups are entirely different. 在大多数情况下,组中的特征完全不同。 These are starter/alternator components.
这些是起动机/交流发电机组件。 Only around 25% of characteristics can overlap, like physical characteristics, length, diameter, etc.
只有大约25%的特征可以重叠,如物理特性,长度,直径等。
I would suggest the following: Create 3 tables; 我建议如下:创建3个表; Groups, GroupCharacteristics,Products.
群组,群体特征,产品。
Groups: 团体:
[GroupName] [组名]
1-Vehicles 1-车辆
2-Furniture 2,家具
Characteristics: 特点:
[Map][Group][Characteristic] [地图] [集团] [特点]
1-C01 | 1-C01 | Vehicles |
车辆| Length
长度
2-C02 | 2-C02 | Vehicles |
车辆| Volume
体积
3-C03 | 3-C03 | Vehicles |
车辆| Type
类型
4-C01 | 4-C01 | Furniture |
家具| Height
高度
5-C02 | 5-C02 | Furniture |
家具| Volume
体积
6-C03 | 6-C03 | Furniture |
家具| Length
长度
Products: 产品介绍:
[ProdName][Group][C01][C02][C03]... [ProdName]的[组] [C01] [C02] [C03] ...
1-Car | 1车| Vehicles |
车辆| 2 |
2 | 50 |
50 | Hatchback
两厢
2-Jet | 2-Jet | Vehicles |
车辆| 10 |
10 | 70 |
70 | Null
空值
3-Table| 3,表| Furniture |
家具| 1 |
1 | null |
null | 1.6
1.6
4-Cup | 4杯| Furniture |0.1 |
家具| 0.1 | 0.12 |
0.12 | null
空值
String col = Select Map from Characteristics where Group = 'Vehicles' and Characteristic = ' Type' String col =从特征中选择地图,其中Group ='Vehicles'和Characteristics ='Type'
-- this returns the column (in this case C03) then -- - 这将返回列(在本例中为C03)然后 -
String sql = "Select ProdName from Products where Group = 'Vehicles' and "+col+"='Hatchback'" String sql =“从产品中选择ProdName,其中Group ='Vehicles'和”+ col +“='Hatchback'”
-- this will build the query in a string then you just execute it -- - 这将在字符串中构建查询然后您只需执行它 -
execute(sql) 执行(SQL)
-- in whatever language you're using this is just the basic idea behind the code you have to write. - 无论您使用何种语言,这只是您必须编写的代码背后的基本思想。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.