Re: Unique Constraint with foreign Key

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: mohan(at)physics(dot)gmu(dot)edu
Cc: pgsql-sql(at)postgresql(dot)org, torque-user(at)db(dot)apache(dot)org
Subject: Re: Unique Constraint with foreign Key
Date: 2004-02-10 20:15:21
Message-ID: 20040210201521.GA13737@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, Feb 10, 2004 at 12:03:36 -0500,
mohan(at)physics(dot)gmu(dot)edu wrote:
> Hi all i am using postgres and torque
> I have a column x in Table A of type varchar and NOT NULL. I want to
> impose a unique key constraint on that table and column y is the primary
> key.
> I have another Table B with column x. can i make this column x as a
> foreign key on column x in table A.

Yes. The reference will need to specify column x, since the primary key
column (y) will be the default.

> or Can i have varchar types of size 50 as primary keys in Postgres.

Yes. But unless the 50 character limit comes from a business rule, you
might want to use the type 'text'.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ramiro Arenas R 2004-02-10 20:45:49 Unable to convert date to tm
Previous Message boyd (remove_) tb_moore_@bealenet_.com 2004-02-10 19:50:45 Re: max timestamp