Tuesday, October 26, 2010

Tree structures in relational database

Into Tree again. I'm a fan of Materialized Path but a bit worried with the limitation to the number of branches. It's ok for something like gov ministry where most of the time the number of agency and department already expected and doesn't change/grow much but with MLM kind of system, we should expect it to expand as wide and depth as possible.

Think better start with adjacency model first (and maybe combined with mat path for easy retrieval). From there it's still possible to move to other models.

http://www.sqlteam.com/article/more-trees-hierarchies-in-sql
http://stackoverflow.com/questions/2797720/sorting-tree-with-a-materialized-path
http://www.ibstaff.net/fmartinez/?p=18

Monday, October 25, 2010

Better pager for psql/mysql client

Very nice tips I found today - http://merlinmoncure.blogspot.com/2007/10/better-psql-with-less.html

If you used psql or mysql client on the console a lot, it always a problem browsing through result set that much wider that your console width.

export PAGER=less
export LESS="-iMSx4 -FX"

Then just make sure your psql/mysql use the correct pager. For mysql, \P would set pager to "less".