Search code examples
sqlpostgresqlnosqlltree

Does using postgres datatypes like ltree, json is related to NoSQL?


While I am designing a table in PostgreSQL, I planned to use ltree or path datatypes to achieve my functionality. But team members are told if we use ltree then our whole table design will become NoSQL format.

Is it true?

If Yes, then how I can achieve this ltree design in SQL format? If No, could you please guide me to understand this?


Solution

  • There is a high probability that you are doing something wrong if you are tempted to use structured data types a lot.

    Data that should in some way be processed by the database (used in expressions or WHERE conditions, indexed, constrained) should normally be kept in simple data types in normalized tables. You should have foreign key constraints to express relationships.

    That said, there is nothing wrong with using the data types you mention occasionally, particularly if these data are not processed inside the database a lot.

    As always in such cases, it is a matter of taste and experience. Just don't fall into the trap of using tables with only a primary key and a jsonb field all the time.