PostgreSQL is not just a relational db, but an object-relational db ⚡
It has a super-cool feature that allows us to create user-defined types and define behaviors (functions) on them. This way, you get the best of both worlds - an ability to organize data into rows and columns and define complex types right in your database.
For example, you can define a type “Book” with fields like id, title, and author and also functions “is_available” on it that when invoked fires another query to check the availability. Pretty cool isn’t it?
Although this means we are keeping fragments of business logic in the database, if it is something invoked more frequently and which rarely changes, then you can dramatically reduce the response time and improve performance by leveraging this.
⚡ I keep writing and sharing my practical experience and learnings every day, so if you resonate then follow along. I keep it no fluff.
youtube.com/c/ArpitBhayani