数据库设计 - 具有属性的多类产品 [英] Database design - multi category products with properties

查看:281
本文介绍了数据库设计 - 具有属性的多类产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为供应商设计一个基本的库存系统。

他们有许多不同的产品类别。

每个产品类别都有许多不同的属性。

I am designing a basic inventory system for a vendor.
They have many different product categories.
Each product category has many different properties.

A - x1,x2,x3,a1,a2,a3;

B - x1,x2,x3,b1,b2,b3, b4;

C - x1,x2,x3,c1,c2;

A - x1, x2, x3, a1, a2, a3;
B - x1, x2, x3, b1, b2, b3, b4;
C - x1, x2, x3, c1, c2;

Laptop - Make, Price, Quantity, Processor, OS, Hard drive, Memory, Video Card etc 
Monitor - Make, Price, Quantity, Size, ContrastRatio, Resolution etc 
Server - Make, Price, Quantity, Processor, OS, Memory, Netowrking etc

Design1:每个类别的不同表。

Design2:常用表,属性表。

Design1: Different tables for each category.
Design2: Common Table, property table.

什么是最好的方法?

推荐答案

绝对不想不必要地增加模式(奥卡姆的规则,你知道)。安排多对多关系的标准方式只是一个中间表:

Definitely don't want to multiply schemas unnecessarily (Occam's rule, y'know). The standard way of arranging many-to-many relationships is simply an intermediate table:

Products
--------
ProductID


Categories
----------
CategoryID


ProductCategories
-----------------
ProductID
CategoryID

它直接查询和行业最佳实践。

Its straightforward to query and an industry best practice.

这篇关于数据库设计 - 具有属性的多类产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆