I’m designing a Database and I have some doubts on using Hierarchical datamodels in relational databases.
If I want to deal with categories, subcategories and parent categories it is possible not to use a Hierarchical datamodels in a relational database? By another words, it is possible to deal with categories, subcategories and parent categories using the relational way of doing things?
By the way, I’m using PostgreSQL.
Sorry for my bad english.
Best Regards,
You have a couple of options to store hierachies:
If you have PostgreSQL version 8.4 or later, you can use recusive queries to make things very easy. This is by far the easiest solution, easy to query, easy to insert new records, easy to update current records, easy to delete records and you have referential integrity. All other solutions have parts that are hard to solve.
Adjency list:
Result: