我需要实现一个电子邮件日志表,它将被一系列实体使用--每个实体代表我们用来创建"emailable“文档的数据。
我如何最好地使用Symfony2和理论在数据库中对这种行为进行建模?有太多的字段不能重用EmailLog表,而且还计划了一些功能,这些功能可能包括一个总体日志视图。
假设我们有这样的文件数据表的报价和订单,对我来说最明智的是
Company\Bundle\Entity\EmailLog:
type: entity
table: email_log
id:
id:
type: integer
nullable: false
unsigned: false
comment: ''
id: true
column: emlo_id
generator:
strategy: IDENTITY
fields:
created_at:
type: datetime
nullable: true
fixed: false
comment: ''
default: ''
to:
type: string
nullable: false
length: 500
fixed: false
comment: ''
Company\Bundle\Entity\EmailLog:
type: entity
table: email_log_link
id:
id:
type: integer
nullable: false
unsigned: false
comment: ''
id: true
column: emlo_id
generator:
strategy: IDENTITY
fields:
quote_id:
type: int
nullable: true
order_id:
type: int
nullable: true有更好的数据库模型吗?
应该用PSR-3记录仪解决这个问题吗?
发布于 2015-09-10 12:28:29
从我在映射文件中看到的情况来看,您似乎在使用Doctrine。
您正在尝试实现的可能是一种反模式,"外星人",一种存储在关系数据库中的对象类型,与其他实体很少或根本没有关系。您正在使用数据库作为持久化的媒介。
为什么不将域模型的这一部分切换到文档数据库?您可以将实体设计为简单的文档,并使用原则ODM将它们映射到Symfony。此外,将实际映射转换为ODM映射非常简单。
https://stackoverflow.com/questions/32388660
复制相似问题