开发者

Database Design - Which design should I use? Two options

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.

Database Design - Which design should I use? Two options

Database Design - Which design should I use? Two options


Update: Just to add an INSERT INTO example

inser开发者_高级运维t 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');


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜