Modeling a cellphone bill: should I use single-table inheritance or polymorphic associations?

Posted by Horace Loeb on Stack Overflow See other posts from Stack Overflow or by Horace Loeb
Published on 2010-04-14T01:50:03Z Indexed on 2010/04/14 1:53 UTC
Read the original article Hit count: 397

In my domain:

  • Users have many Bills
  • Bills have many BillItems (and therefore Users have many BillItems through Bills)
  • Every BillItem is one of:
    • Call
    • SMS (text message)
    • MMS (multimedia message)
    • Data

Here are the properties of each individual BillItem (some are common):

alt text

My question is whether I should model this arrangement with single-table inheritance (i.e., one "bill_items" table with a "type" column) or polymorphism (separate tables for each BillItem type), and why.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about ruby-on-rails