[英]What is the best approach to relating tables with scalability in mind
Using MySQL, I am implementing the Party pattern, where parties maybe people or organisations. 使用MySQL,我正在实现“聚会”模式,其中聚会可能是人员或组织。 A party may also be a customer, supplier etc etc.
一方也可以是客户,供应商等。
What is the best way to relate this? 与此相关的最佳方法是什么?
Customer, Supplier, etc Tables with 1:1 to the Party table. 客户表,供应商表等与Party表的比例为1:1的表。
OR 要么
PartyType Table with unique rows inc Customer, Supplier etc that relates 1:1 in the Party table. 具有唯一行的PartyType表,包括与Party表中的1:1相关的Customer,Supplier等。
I am trying to working out what is better for scaling up to possible large number of Party records. 我正在尝试找出最适合扩大大量党派记录的方法。
eg: 例如:
Select * From Suppliers Inner Join Party … 选择*从供应商内部加入聚会…
OR 要么
Select * From Party Where PartyType = "supplier" 选择* From Party,其中PartyType =“供应商”
I have initial thoughts, but not sure if they are valid: 我有初步想法,但不确定它们是否有效:
Suppliers will hold less records to search on so maybe thats optimal, But then is MySQL clever enough to HOP through large Party table only picking up PartyType = 'Suppliers. 供应商将保留较少的记录以进行搜索,因此可能是最佳选择,但是MySQL足够聪明,可以通过大型Party表进行HOP,而只需选择PartyType ='Suppliers。
Does it even matter? 有关系吗
As always if you are concerned about performance: go test it! 与以往一样,如果您担心性能,那就去测试吧! And if the performance is good in either case, take the better design in regard of normalisation and such.
并且,如果在两种情况下的性能均良好,则在标准化等方面采用更好的设计。
But to get to you question, MySQL (as any other relevant DB System) is very efficient in querying big tables for information. 但是让您感到疑问的是,MySQL(与任何其他相关的数据库系统一样)在查询大表中的信息时非常有效。 I think option A works best.
我认为选项A效果最好。 You need an index on the referenced column of the party, but since it is quite likely that this is the primary key, you have good chances that this design works good out of the box.
您需要在该方的引用列上创建一个索引,但是由于很有可能这是主键,因此很有可能该设计可以立即使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.