数据库设计 - 我应该使用哪种设计?两种选择

发布于 2024-10-15 19:16:55 字数 2906 浏览 1 评论 0原文

我正在使用 PostgreSQL 设计数据库架构。我对应该使用哪种设计有一些疑问。

tdir_details_uris_text将有数百万个寄存器,每个关键domainuriid_language将有大约10/ 20 个寄存器。

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

最好的问候,

PS:抱歉我的英语不好。

在此处输入图像描述

在此处输入图像描述


更新:仅添加 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');

I'm designing a database schema using PostgreSQL. I have some doubts about which design should I use.

The table tdir_details_uris_text will have many millions of registers, each key domain, uri, id_language will have about 10/20 registers.

Which design should perform well? The 3 tables design or the 2 tables design?

Best Regards,

PS: Sorry for my poor English.

enter image description here

enter image description here


Update: Just to add an INSERT INTO example

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');

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

少钕鈤記 2024-10-22 19:16:55

听起来像是多对多关系,这需要三表设计。

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

表 A 将 ID_A 作为主键。

表 B 将 ID_B 作为主键。

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

Sounds like a many-to-many relationship, which would require a three table design.

But I don't think it's the design you show. I don't see the correct primary key relationship.

Table A would have ID_A as primary key.

Table B would have ID_B as primary key.

The JOIN Table AB would have primary key ID_A, ID_B; each one would be a foreign key into Table A and B, respectively.

疏忽 2024-10-22 19:16:55

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

Your "tdirs_uris_text" table in option 1 has no purpose that I can see (if you only have the two tables in your entire design). The question to ask is whether the primary key in "tdirs_uris_text" will ever be used multiple times on a different table (as a foreign key). Specifically, would there ever be a case where the "details" table has the "uris" foreign key appear multiple times? If so option 1 is better otherwise option 2 is preferred.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文