创建数据库结构产品属性映射 [英] creating database structure product attribute mapping

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

问题描述

我必须管理数据库中的产品很少



1:某些类别的产品(如男性/女性)

尺寸不同每个



2:每种产品尺寸都有不同颜色



3:产品数量取决于尺寸和颜色



喜欢:tshirt>> XL>>红色>> 2

shoe>> 19>>黑>> 4



一些产品我不依赖于尺寸或颜色或两者



喜欢:钱包> >红色>> 10

:Latop>> 19英寸> 12



请帮忙吗?

i have to manage product in db with few

1:product of some category like men / women have
size different for each

2: each product size comes in different colors

3:qty of product will depend on both size and color

like : tshirt >> XL >> red >> 2
shoe >> 19 >> black >> 4

some product my not have dependency on size or colors or both

like : wallet >> red >> 10
: Latop >> 19" inch >> 12

please do help ?

推荐答案

这样的事情怎么样?数据库结构类似于以下内容(如果数组没有意义)。



ID |产品| Desc | Attr

---------------------------



ID将持有产品的ID号(唯一键,自动增量)。



产品将保留产品名称。



Desc将保留描述



Att将按以下格式保存属性(如大小,颜色,性别......)。



Attr:价值;

大小:9;



What about something like this? The database structure would be something like the following (in case the array doesn't make sense).

ID | Product | Desc | Attr
---------------------------

ID would hold the product's ID number (unique key, auto increment).

Product would hold the product name.

Desc would hold the description

Att would hold the attributes (like size, color, gender...) in the following format.

Attr: Value;
Size: 9;

// Example array as it would be from the database


db = array(
array(' ID' => ' 1'
' 产品' => ' 电子钱包'
' Desc' => ' 红色钱包'
' Attr' => ' 颜色:红色;'
),
数组( ID' => ' 2'
' 产品' => ' 鞋子
' Desc' => ' 一只步行鞋'
' Attr' => ' 颜色:白色;
性别:女;
尺寸:11.5;'

),
数组(' ID' => ' 3'
' 产品' => ' 笔记本电脑'
' Desc' => ' Dell Inspiring Laptop'
' Attr' => ' 颜色:银色;
大小:19;'

),
数组(' ID' => ' 4'
Product' => ' Sock'
' Desc' => ' Nike Sock'
' Attr' => ' 颜色:白色;
大小:9;'

),
);

// < span class =code-comment>完成结果
fore ach(
db = array( array('ID' => '1', 'Product' => 'Wallet', 'Desc' => 'A red wallet', 'Attr' => 'Color: Red;' ), array('ID' => '2', 'Product' => 'Shoe', 'Desc' => 'A walking shoe', 'Attr' => 'Color: White; Gender: Female; Size: 11.5;' ), array('ID' => '3', 'Product' => 'Laptop', 'Desc' => 'A Dell Inspiring Laptop', 'Attr' => 'Color: Silver; Size: 19";' ), array('ID' => '4', 'Product' => 'Sock', 'Desc' => 'Nike Sock', 'Attr' => 'Color: White; Size: 9;' ), ); // Going through the results foreach(


db as
db as


这篇关于创建数据库结构产品属性映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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