From: lucas@presserv.org
To: pgsql-sql@postgresql.org
Subject: Chield Serial
Date: Mon, 4 Apr 2005 10:01:02 -0300
Message-ID: <20050404100102.z7ohducpsei8s0c8@www.presserv.org> (raw)
Hi.
Is there a way to make a serial columm that works with father table???
I.e:
I have created a table called "vending" and its chield table called "items".
The items table have a serial columm, but I need the serial colum starts with 0
for each vending.
create table vending (
id serial primary key, --Ok, this serial: 0 - 9999xxx
date_ date
);
create table items (
vending_id references vending,
items_id serial, -- THIS SERIAL NEED to start 0 for each vending_id
primary key (vending_id,items_id)
);
insert into vending values (1,now());
insert into vending values (2,now());
insert into items values (1);
insert into items values (1);
insert into items values (2);
insert into items values (2);
select * from items;
vending_id | items_id
1 | 1
1 | 2
2 | 3 <<=== Here! The items_id need to be 1 (start again
for each vending_id)
2 | 4 <<==
Thanks all.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: lucas@presserv.org
Subject: Re: Chield Serial
In-Reply-To: <20050404100102.z7ohducpsei8s0c8@www.presserv.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox