X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 55102533EE for ; Mon, 4 Apr 2005 14:01:14 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01373-03 for ; Mon, 4 Apr 2005 13:01:07 +0000 (GMT) Received: from iracema.dnscenter.com.br (iracema.dnscenter.com.br [67.15.80.70]) by svr1.postgresql.org (Postfix) with ESMTP id 414885341B for ; Mon, 4 Apr 2005 14:01:05 +0100 (BST) Received: from cpanel by iracema.dnscenter.com.br with local (Exim 4.50) id 1DIRCQ-0006Yc-Ry for pgsql-sql@postgresql.org; Mon, 04 Apr 2005 10:01:02 -0300 Received: from 200.158.187.47 ([200.158.187.47]) by www.presserv.org (Horde) with HTTP for ; Mon, 4 Apr 2005 10:01:02 -0300 Message-ID: <20050404100102.z7ohducpsei8s0c8@www.presserv.org> Date: Mon, 4 Apr 2005 10:01:02 -0300 From: lucas@presserv.org To: pgsql-sql@postgresql.org Subject: Chield Serial MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) H3 (4.0) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iracema.dnscenter.com.br X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [32001 502] / [47 12] X-AntiAbuse: Sender Address Domain - presserv.org X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.164 tagged_above=0 required=5 tests=AWL, NO_REAL_NAME, RCVD_IN_NJABL_PROXY X-Spam-Level: * X-Archive-Number: 200504/45 X-Sequence-Number: 20938 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.