Hi,

i have a table like this:

create table array (
  account text NOT NULL,
  id      int4 NOT NULL,
  value   text NOT NULL,
  PRIMARY KEY (account, id)
);

values like this:

acc1,1,'hi'
acc1,2,'ho'
acc1,3,'ha'
acc2,1,'ho'
acc3,1,'he'
acc3,2,'hu'

"id" should be positive 
"id" should not have gaps within the same account
"id" should start counting by 1 for each account

i cant use sequences because they are producing gaps and doesn't start 
counting by 1 for each account and i dont want to use postgresql array type 
for various reasons.

for this model to function you need a lot of sophisticated plpgsql function to 
insert, move or delete entries to keep 

- did anyone implemented a table like this and wrote some custom 
functions/triggers for inserting, deleting, moving and so on? If yes it would 
be nice if he/she is willing to sahre the code with me.

- did anyone implemented a table like this and came to the conclusion that 
this shouldn't be done for any reasons out of my sight? (i don't bother about 
updating a primary key)

kind regards,
janning





---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

Reply via email to