Storing a chain

Поиск
Список
Период
Сортировка
От Johan Fredrik Øhman
Тема Storing a chain
Дата
Msg-id E1AMTvX-0003VE-8s@mail-mx1.uio.no
обсуждение исходный текст
Ответы Re: Storing a chain  (Bruno Wolff III <bruno@wolff.to>)
Re: Storing a chain  (Herbert Liechti <herbert.liechti@thinx.ch>)
Re: Storing a chain  ("Keith C. Perry" <netadmin@vcsn.com>)
Список pgsql-general
Hi,
I'm seeking some opinion on the following problem

For those familiar with "iptables/netfilter", I am actually storing firewall
rules in the database. The order of these rules is critical, so there has to
be some kind of system to how they are ordered. As I see it there are at
least 2 approaches.

1) Use a Sequence number in the table. This way it is possible to use ORDER
BY sequencenumber to retrive the correct list.  This works, but you have to
do some massive updating when you what to insert a rule between i.e "12" and
"13".


CREATE TABLE FW_CHAIN (
         FW_CHAIN_ID          INT4                 not null,
         PARENT_ID            INT4                 null,
          ....  fields ..............
         constraint PK_FW_CHAIN primary key (FW_CHAIN_ID)
);

2) Use a Parent_Id, as described intended in the table above.  I feel that
this is a little prettier, even if it might be somewhat less efficient.
Unfortunately, I'm really not sure how to perform the queries.  As I see it
some kind of recursive select statement is needed. Cursors ?  Stored
Procedure?

If somebody has the time, I'd really appreciate some links to relevant
examples, documentation or advice on how to solve this.

--
Johan Fredrik Øhman



В списке pgsql-general по дате отправления:

Предыдущее
От: Herbert Liechti
Дата:
Сообщение: Wanted: Trick for granting permissions to users with hyphens
Следующее
От: Carmen Gloria Sepulveda Dedes
Дата:
Сообщение: Re: Problem with exec sql include