2011-11-17 38 views
0

我目前正在为我工​​作的公司开发产品库存信息的数据库存储解决方案。我正在使用MySql,而且我很难为数据存储提供一种高效可行的格式。MySql数据库格式

因为它现在工作,我们有〜25000产品跟踪。对于每种产品,我们需要追踪20种不同的类别(数量,价格等)。此报告每3-4天下载并更新一次,现在在Excel中存储和更新。

我的问题是我迄今为止提出的唯一解决方案是为每个上述类别创建单独的表,使用基于产品skus的外键和级联来更新每个相应的表。但是,这种方法要求每次运行程序时每个表添加24000行,因为每个产品都需要更新其运行日期。问题在于数据将存储大约一年,所以表格将增加大量。我对其他数据库格式的研究已经产生了一些例子,但没有一个在这个范围内。他们的目标是每天增加100行。

有没有人知道或有任何想法建立这种类型的数据库的适当方式,或者我上面描述的方法适合并在MySql表的限制内?

谢谢, 迈克

回答

0

25,000行是什么到MySQL或这种情况下的平面文件。最初不要担心数据量。我从事过许多零售数据库模式,产品通常由静态或任意长度的一组属性定义。您的数据量结束时不会太远。

静态:

create table products (
    product_id integer primary key auto_increment 
    , product_name varchar(255) -- or whatever 
    , attribute1_id -- FK 
    , attribute2_id -- FK 
    , ... 
    , attributeX_id -- FK 
); 

create table attributes (
    attribute_id integer primary key -- whatever 
    , attribute_type -- Category? 
    , attribute_value varchar(255) 
); 

或者,你明明:

create table products (
    product_id integer primary key auto_increment 
    , product_name varchar(255) -- or whatever 
); 

create table product_attributes (
    product_id integer 
    , attribute_id integer 
    , -- other stuff you want like date of assignment 
    , primary key (product_id , attribute_id) 
); 

create table attributes (
    attribute_id integer primary key -- whatever 
    , attribute_type -- Category? 
    , attribute_value varchar(255) 
); 

我会毫不犹豫地推几百万元的记录到喜欢的方式的基本结构。

+0

Xepoch,谢谢你的回应。这是非常有用的,我会在开始开发这个数据库时参考你的建议。正如我对mysql和数据库格式的新手一样,有经验的老手帮助我很好。 – SubxZero

相关问题