Add polymorphic type() method to the database classes