简体   繁体   English

将表与可伸缩性相关联的最佳方法是什么

[英]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.

相关问题 关联数据库或表的最佳方法? - Best approach to relating databases or tables? 从长远来看,创建SQL表以轻松查询的最佳方法是什么? - What is best approach to creating SQL tables to easily query in the long run? 将MySQL连接查询与OOP和对象相关联的最佳实践方法 - Best Practice approach to relating MySQL join queries to OOP and Objects 在考虑规范化和可扩展性的情况下接近数据库时,您对在表列中使用文本标识符有何看法? - What is your opinion on using textual identifiers in table columns when approaching the database with normalization and scalability in mind? 考虑到速度和安全性,从MySQL调用数据的最佳方法是什么? - what is the best way to call data from MySQL with speed and security in mind? 加入这两张桌子的方法是什么? - What's the approach to joining these 2 tables? MySQL查询包含三个表,一个表是自引用的,并且具有相同的字段。 最好的方法是什么? - MySQL query with three tables, one self referenced and with same fields. What's the best approach? 我的最佳方法是:根据抓取的数据创建计算表 - What's my best approach re: creating calculated tables based on scraped data 跨 EC Core 上下文同步大型数据库表的最佳方法是什么? - What is the best approach to synchronizing large database tables across EC Core contexts? 从多个表中选择的最佳方法 - Best approach to select from multiple tables
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM