优势和Ruby的优缺点on Rails的多态关系 [英] Advantages and disadvantages of Ruby on Rails polymorphic relationships
问题描述
您了解Ruby的哪些优点和缺点都on Rails的多态关系。
What advantages and disadvantages do you know of Ruby on Rails polymorphic relationships.
推荐答案
优势:
- 您可以很容易地任何连接到任何
- 在适应关系有助于容纳不可预见的情况
- 很容易实现的关系
- 伟大的点对点系统
缺点:
- 外键不实用
- 在指标包括复杂性的另一个方面 表硬盘之间的
- 在关系到使用STI时,确定
- 在数据库绘图工具,不能跨preT
- 在并不总是可行的加盟模式
- 不赞成为系统中数据的完整性,必须验证
- Foreign keys not practical
- Indexes include another dimension of complexity
- Relationships between tables hard to identify when using STI
- Database diagramming tools cannot interpret
- Not always practical for join models
- Strongly discouraged for systems where data integrity must be verified
我用这样的关系对连接到大量的东西,记录的要求,例如一个大风扇,评论或注解记录可能适用于各种各样的记录。
I'm a big fan of using relationships of this sort for records that are attached to a large number of things as required, for example, a comment or annotation record which may apply to a wide variety of records.
它不适合非常好,其中的关系是经常一个JOIN行使的情况。即,多态型的关联不应该在的记录之间的关系的中间,但作为东西上的周长。
It is not very well suited for situations where the relationship is exercised in a JOIN frequently. That is, the polymorphic association should not be in the middle of a relationship between records, but as something on the perimeter.
这篇关于优势和Ruby的优缺点on Rails的多态关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!