首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >多个实体的EmailLog表

多个实体的EmailLog表
EN

Stack Overflow用户
提问于 2015-09-04 01:09:55
回答 1查看 85关注 0票数 2

我需要实现一个电子邮件日志表,它将被一系列实体使用--每个实体代表我们用来创建"emailable“文档的数据。

我如何最好地使用Symfony2和理论在数据库中对这种行为进行建模?有太多的字段不能重用EmailLog表,而且还计划了一些功能,这些功能可能包括一个总体日志视图。

假设我们有这样的文件数据表的报价和订单,对我来说最明智的是

代码语言:javascript
复制
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记录仪解决这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-10 12:28:29

从我在映射文件中看到的情况来看,您似乎在使用Doctrine。

您正在尝试实现的可能是一种反模式,"外星人",一种存储在关系数据库中的对象类型,与其他实体很少或根本没有关系。您正在使用数据库作为持久化的媒介。

为什么不将域模型的这一部分切换到文档数据库?您可以将实体设计为简单的文档,并使用原则ODM将它们映射到Symfony。此外,将实际映射转换为ODM映射非常简单。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32388660

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档