take a look on contrib/ltree On Wed, 26 Sep 2007, paul.dorman wrote:
Hi everyone, I would like to know the best way to implement a DAG in PostgreSQL. I understand there has been some talk of recursive queries, and I'm wondering if there has been much progress on this. Are there any complete examples of DAGs which work with PostgreSQL? I would like to be able to do the following operations for a categorization system: 1. Given a node, get one or more field values out of every parent node 2. Given a parent node, get one or more field values out of every child node 3. Given two or more parent nodes, identify any common children. I do not need to determine shortest paths between parents and children, only to be able to iterate over them as efficiently as possible. I'd like to keep things dynamic so changes up the hierarchy don't require changes to any of the children (unless their direct parents are changed). I'd also like to keep as much processing as possible in the database to minimize the traffic between my application and the DB, so I think I'm looking for SQL and stored procedure solutions. Any pointers would be great, as I'm not a DBA and do not have the experience to make judgments about the best possible approach. Regards, Paul Dorman ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq
Regards, Oleg _____________________________________________________________ Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru), Sternberg Astronomical Institute, Moscow University, Russia Internet: oleg@xxxxxxxxxx, http://www.sai.msu.su/~megera/ phone: +007(495)939-16-83, +007(495)939-23-83 ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match