请教一个数据库设计的问题 现在做一个商场的网站,网站中有各种商品,比如手机,化妆品,服装···,每种商品的属性是不同的,手机有手机的参数,服装又有服装的参数,而且与手机的参数完全不同,但是又同属于商品,如果只做一个商品表,那这么多的属性如何处理啊。本人数据库这比较菜鸟,希望大虾指点迷津。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 手机表:ID 商品ID 品牌 型号 颜色 是否翻盖 等……化妆品表:ID 商品ID 品牌 颜色 等……服装表:ID 商品ID 品牌 男女款式 等……总表:ID 商品ID 种类 等……我随便写的,其中化妆品表可能还要根据是那种化妆品来具体细分? 个人愚见tab1:总商品ID--TYPE--......tab2:商品PID--PTYPE--ARG1--ARG2--....ARGn yy一个,请各位高人指点use tempdb;--属性表create table attribute( attributeid int identity(1,1) not null primary key, categoryid int not null, attributename nvarchar(10) not null);insert into attribute(categoryid,attributename)values(1,'操作系统'),(2,'颜色');--分类表create table category( categoryid int identity(1,1) not null primary key, categoryname nvarchar(10) not null);insert into category(categoryid,categoryname)values(1,'手机'),(2,'服装');--商品表create table goods( goodsid int identity(1,1) not null primary key, categoryid int not null, goodsname nvarchar(10) not null);insert into goods(categoryid,goodsname)values(1,'华为C8500'),(1,'iPhone 4'),(1,'HTC S1'),(2,'阿迪王春哥限量版板鞋');--商品属性表create table goods_attribute( goods_attribute_id int identity(1,1) not null primary key, goodsid int not null, attributeid int not null, attributevalue int not null --属性值);insert into goods_attribute(goodsid,attributeid,attributevalue)values(1,1,'Android系统'), --描述 华为C8500 的操作系统为Android(1,2,'银灰色'), --描述 华为C8500 的颜色为银灰色(2,1,'iPhone系统'), --描述 iPhone 4 的操作系统为iPhone(2,2,'黑色'), --描述 iPhone 4 的颜色为银灰色(3,1,'Windows Mobile 6系统'),(3,2,'黑色'),(4,2,'粉色'), --描述 阿迪王春哥限量版板鞋 的颜色为粉色 求一条SQL语句,非自然月跨月查询 高手看看这个SQL? 分组统计显示 一个小问题 sql 如何把多个列合成一个列,然后查询? 如何求表中相邻(按聚集索引相邻)的两条记录的某字段的值之差,用Transact-SQL语句或存储过程。 请问ole db是什么方面的数据库,最好举个例子 一个表读出两份重复的列记录 求一条update语句 请问ms sql中日期时间型字段捆绑到vfp的编辑框中如何不显示时间部分??? 请解释一下:sql2005的数据库角色成员身份 改名
ID 商品ID 品牌 型号 颜色 是否翻盖 等……
化妆品表:
ID 商品ID 品牌 颜色 等……
服装表:
ID 商品ID 品牌 男女款式 等……总表:
ID 商品ID 种类 等……我随便写的,其中化妆品表可能还要根据是那种化妆品来具体细分?
个人愚见tab1:总商品
ID--TYPE--......tab2:商品
PID--PTYPE--ARG1--ARG2--....ARGn
use tempdb;--属性表
create table attribute
(
attributeid int identity(1,1) not null primary key,
categoryid int not null,
attributename nvarchar(10) not null
);
insert into attribute(categoryid,attributename)
values
(1,'操作系统'),
(2,'颜色');--分类表
create table category
(
categoryid int identity(1,1) not null primary key,
categoryname nvarchar(10) not null
);
insert into category(categoryid,categoryname)
values
(1,'手机'),
(2,'服装');--商品表
create table goods
(
goodsid int identity(1,1) not null primary key,
categoryid int not null,
goodsname nvarchar(10) not null
);
insert into goods(categoryid,goodsname)
values
(1,'华为C8500'),
(1,'iPhone 4'),
(1,'HTC S1'),
(2,'阿迪王春哥限量版板鞋');--商品属性表
create table goods_attribute
(
goods_attribute_id int identity(1,1) not null primary key,
goodsid int not null,
attributeid int not null,
attributevalue int not null --属性值
);
insert into goods_attribute(goodsid,attributeid,attributevalue)
values
(1,1,'Android系统'), --描述 华为C8500 的操作系统为Android
(1,2,'银灰色'), --描述 华为C8500 的颜色为银灰色
(2,1,'iPhone系统'), --描述 iPhone 4 的操作系统为iPhone
(2,2,'黑色'), --描述 iPhone 4 的颜色为银灰色
(3,1,'Windows Mobile 6系统'),
(3,2,'黑色'),
(4,2,'粉色'), --描述 阿迪王春哥限量版板鞋 的颜色为粉色