Received: from 213-145-170-138.dd.nextgentel.com (213-145-170-138.dd.nextgentel.com [213.145.170.138]) by postgresql.org (8.11.3/8.11.4) with SMTP id fB5L6Gm00415 for ; Wed, 5 Dec 2001 16:06:16 -0500 (EST) (envelope-from postgresql@envisity.com) Received: (qmail 7248 invoked by uid 67); 5 Dec 2001 21:03:56 -0000 Message-ID: <20011205210356.25680.qmail@213-145-170-138.dd.nextgentel.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: inline MIME-Version: 1.0 From: "Aasmund Midttun Godal" To: martin@bugs.unl.edu.ar Cc: pgsql-sql@postgresql.org Subject: Re: INT OR VARCHAR Date: Wed, 05 Dec 2001 21:03:56 GMT X-Mailer: Googley-Moogley In-Reply-To: <20011205204142.AA74CFA61@bugs.unl.edu.ar> from MartíN MarquéS on Wed, 5 Dec 2001 17:41:40 -0300 References: <20011205204142.AA74CFA61@bugs.unl.edu.ar> Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by postgresql.org id fB5LRCL01571 X-Archive-Number: 200112/56 X-Sequence-Number: 5879 I am not sure what you are trying to do, but if you have a tree structure you will have to use an id column e.g.: CREATE TABLE domain ( id SERIAL PRIMARY KEY, name TEXT CHECK (lower(name) ~ '[a-z0-9]([a-z0-9-]*[a-z0-9])?', parent INTEGER REFERENCES domain, UNIQUE (parent, name) ); If you do not have a tree structure, I would recommend using a natural primary key in stead of serializing it. Bear in mind though - you should always have a primary key. I would also recommend creating a couple of functions to build a fully qualified domain name from the id. Regards, Aasmund. On Wed, 5 Dec 2001 17:41:40 -0300, Martín Marqués wrote: > I have a table that will be populated with machines of a net we have. And we > have more then 1 domain, so we thought about putting a seperate table with > the domains, and a reference in the nodes table to the apropiate domain. > > The question is, should I put an SERIAL field in the domain table and use > that as the PK, and use an INT reference in the nodes table? > Or is it a good idea to just leave the domain name (a CHAR(30) field) in the > domain table and make the node.domain a CHAR(30) that references to > domain.name? > What would be the best approche? > > Saludos... :-) > > -- > Porqué usar una base de datos relacional cualquiera, > si podés usar PostgreSQL? > ----------------------------------------------------------------- > Martín Marqués | mmarques@unl.edu.ar > Programador, Administrador, DBA | Centro de Telematica > Universidad Nacional > del Litoral > ----------------------------------------------------------------- > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster Aasmund Midttun Godal aasmund@godal.com - http://www.godal.com/ +47 40 45 20 46