自定义票证系统的最佳数据库表布局/设计

时间:2010-04-14 22:14:55

标签: mysql database-design symfony1

我正在开发一个用于网络管理的自定义故障单系统,并尝试为以下方案找到最佳的数据库表布局:

有表格代表PON,T1和T3线。每行可能有一个或多个故障单,但每个故障单都有一些独特的字段取决于该tiket所属的行类型。

这是我的方法:

pon:
  pon_id, pk
  ....
  #here other unique pon table columns

t1:
  t1_id, pk
  ....
  #here other unique t1 table columns

t3:
  t3_id, pk
  ....
  #here other unique t3 table columns

ticket:
  ticket_id, pk
  type, string # t1, t3, pon
  type_id, int # id of pon, t1 or t3
  ....
  #here other columns, which are common for all ticket types 


ticket_pon_type:
  ticket_id, pk, fk
  ....
  #here unique pon ticket columns


ticket_t1_type:
  ticket_id, pk, fk
  ....
  #here unique t1 ticket columns


ticket_t3_type:
  ticket_id, pk, fk
  ....
  #here unique t3 ticket columns

我正在使用带有Doctrine ORM的Symfony 1.4 PHP框架构建我的应用程序。

还有其他想法吗?谢谢你的帮助。

1 个答案:

答案 0 :(得分:2)

pont1t3应合并到一个表中。在表格中添加line列,以便您可以判断每条记录是pont1还是t3

我认为您会发现这也可以让您整合ticket_type表。