0

so with Postgres I am able to use the json-type column. So with classic relational database I use Class Table Inheritance, which seems cumberstone. Instead I can now use Postgres and just serialize my different subclasses into json and store them in a common table.

Does this approach have any considerable downsides or is it good to use (at least for "simple" use-cases)?

Tim Joseph
  • 847
  • 2
  • 14
  • 28
  • 1
    Inheritance means something different in databases than in OOP. I wrote about this a bit here: http://stackoverflow.com/questions/3074535/when-to-use-inherited-tables-in-postgresql/16169950#16169950 . – zxq9 Nov 12 '15 at 03:07
  • 3
    It'll be painful to query, inefficient to update, etc. http://blog.2ndquadrant.com/postgresql-anti-patterns-unnecessary-jsonhstore-dynamic-columns/ – Craig Ringer Nov 12 '15 at 05:29
  • @zxq9 Sorry I did not express this in my questions clearly, but I meant http://martinfowler.com/eaaCatalog/classTableInheritance.html and not Postgres inherited tables. – Tim Joseph Nov 12 '15 at 09:55
  • @CraigRinger thank you very much! I think my real question is: Since relational databases are cumberstone to use for modelling OOP-Inheritance, is using json the better of two evils? – Tim Joseph Nov 12 '15 at 10:02
  • @Tim json is better used for unstructured data which is not OOPs case. Using it to avoid proper normalization is very bad design. – Clodoaldo Neto Nov 12 '15 at 11:08
  • Any updates on this? I want to do the same and there are no strong conclusions... – Leandro May 16 '18 at 13:58

0 Answers0