Re: [HACKERS] Tree type, how best to impliment?
От | Terry Mackintosh |
---|---|
Тема | Re: [HACKERS] Tree type, how best to impliment? |
Дата | |
Msg-id | Pine.LNX.3.95.981117092113.31230A-100000@terry1.acun.com обсуждение исходный текст |
Ответ на | Tree type, how best to impliment? (Terry Mackintosh <terry@terrym.com>) |
Список | pgsql-hackers |
Hi again I got to thinking that doing a tree address like this, the parent address is all but the last dot-number of the current address, so is redundant, as it can be derived from the current address. So, the new idea looks something like this: CREATE TABLE categories ( category char(30) NOT NULL, cat_id char(255) PRIMARY KEY, nidsufix int4 DEFAULT 1 NOT NULL, UNIQUE ( category, substr(cat_id, 1, lenght(cat_id) - (lenght(cat_id) - strpos(cat_id,'.'))))); Two problems 1. functions can not be called from inside of the UNIQUE constraint? 2. strpos() returns the FIRST '.', and I need the LAST '.'. Is there a similar function that will return the last position of the substring? If both of these can not be resolved, then it will be neccesary to use a parent id field, even though that infomation is contained with in the cat_id field. Thanks Terry Mackintosh <terry@terrym.com> http://www.terrym.com sysadmin/owner Please! No MIME encoded or HTML mail, unless needed. Proudly powered by R H Linux 4.2, Apache 1.3, PHP 3, PostgreSQL 6.4 ------------------------------------------------------------------- Success Is A Choice ... book by Rick Patino, get it, read it!
В списке pgsql-hackers по дате отправления: