2011-02-05 52 views
1

我正在使用PostgreSQL设计数据库模式。我对使用哪种设计有些疑问。数据库设计 - 我应该使用哪种设计?两个选项

tdir_details_uris_text将具有数百万个寄存器,每个密钥domain,uri,id_language将具有大约10/20个寄存器。

哪种设计应该表现良好? 3桌设计或2桌设计?

最好的问候,

PS:对不起,我的英文不好。

enter image description here

enter image description here


更新:我想补充一个INSERT INTO例如

insert into tdir_details_uris_text (domain, uri, id_language, id_categorie, id_data, id_ordinal, n_text) values ('motors.shop.ebay.com', 'http://cgi.ebay.com/ebaymotors/2009-FORD-MUSTANG-GT-BLACK-BEAUTY-16K-MILES-WOW-/230580626087?pt=US_Cars_Trucks&hash=item35afad22a7', 'en', '23', 'title_webpage', '1', '2009 Ford Mustang GT'); 
insert into tdir_details_uris_text (domain, uri, id_language, id_categorie, id_data, id_ordinal, n_text) values ('motors.shop.ebay.com', 'http://cgi.ebay.com/ebaymotors/2009-FORD-MUSTANG-GT-BLACK-BEAUTY-16K-MILES-WOW-/230580626087?pt=US_Cars_Trucks&hash=item35afad22a7', 'en', '23', 'highlights', '1', 'No Accidents/Damage Reported to CARFAX'); 
insert into tdir_details_uris_text (domain, uri, id_language, id_categorie, id_data, id_ordinal, n_text) values ('motors.shop.ebay.com', 'http://cgi.ebay.com/ebaymotors/2009-FORD-MUSTANG-GT-BLACK-BEAUTY-16K-MILES-WOW-/230580626087?pt=US_Cars_Trucks&hash=item35afad22a7', 'en', '23', 'highlights', '2', 'No Airbag Deployment Reported to CARFAX'); 
insert into tdir_details_uris_text (domain, uri, id_language, id_categorie, id_data, id_ordinal, n_text) values ('motors.shop.ebay.com', 'http://cgi.ebay.com/ebaymotors/2009-FORD-MUSTANG-GT-BLACK-BEAUTY-16K-MILES-WOW-/230580626087?pt=US_Cars_Trucks&hash=item35afad22a7', 'en', '23', 'highlights', '3', 'Vehicle Qualifies for the CARFAX Buyback Guarantee'); 
insert into tdir_details_uris_text (domain, uri, id_language, id_categorie, id_data, id_ordinal, n_text) values ('motors.shop.ebay.com', 'http://cgi.ebay.com/ebaymotors/2009-FORD-MUSTANG-GT-BLACK-BEAUTY-16K-MILES-WOW-/230580626087?pt=US_Cars_Trucks&hash=item35afad22a7', 'en', '23', 'highlights', '4', 'No Structural/Frame Damage Reported to CARFAX'); 
insert into tdir_details_uris_text (domain, uri, id_language, id_categorie, id_data, id_ordinal, n_text) values ('motors.shop.ebay.com', 'http://cgi.ebay.com/ebaymotors/2009-FORD-MUSTANG-GT-BLACK-BEAUTY-16K-MILES-WOW-/230580626087?pt=US_Cars_Trucks&hash=item35afad22a7', 'en', '23', 'highlights', '5', 'No Manufacturer Recalls Reported to CARFAX'); 
insert into tdir_details_uris_text (domain, uri, id_language, id_categorie, id_data, id_ordinal, n_text) values ('motors.shop.ebay.com', 'http://cgi.ebay.com/ebaymotors/2009-FORD-MUSTANG-GT-BLACK-BEAUTY-16K-MILES-WOW-/230580626087?pt=US_Cars_Trucks&hash=item35afad22a7', 'en', '23', 'highlights', '6', 'No Indication of an Odometer Rollback'); 
+0

真正的问题是:哪种设计更适合Model *和* Relation Algebra?总是从那里开始。 – 2011-02-05 19:52:42

+0

在tdir_detauls_uris_text和tdir_uris_text中是否存在domain/url/id_language的原因?这似乎是模型中的一个缺陷,只是一目了然。无论如何,我不确定试图呈现的真实“模型”。它是一个还是多个等等?确保捕获该要求。 – 2011-02-05 19:55:18

回答

0

选项1中的“tdirs_uris_text”表没有目的,我可以看到(如果在整个设计中只有两个表)。要问的问题是,“tdirs_uris_text”中的主键是否会在不同的表(作为外键)上多次使用。具体来说,是否会有“情况”表具有多次出现“uris”外键的情况?如果是这样,选项1更好,否则选项2是首选。

1

听起来像许多一对多的关系,这将需要三个表设计。

但我不认为这是你展示的设计。我没有看到正确的主键关系。

表A将ID_A作为主键。

表B将ID_B作为主键。

JOIN表AB将有主键ID_A,ID_B;每一个分别是表A和B的外键。

相关问题