Re: REFERENCES troubles - Mailing list pgsql-general

From Robert B. Easter
Subject Re: REFERENCES troubles
Date
Msg-id 00070418482603.01354@comptechnews
Whole thread Raw
In response to REFERENCES troubles  ("planx plnetx" <planetx2100@hotmail.com>)
List pgsql-general
On Tue, 04 Jul 2000, planx plnetx wrote:
> I get this error when creating a database:
>
> CREATE TABLE workers(
>   name        varchar(30),
>   firstname   varchar(30),
>   id_personal decimal(10)NOT NULL UNIQUE PRIMARY KEY,
> );
>
> CREATE TABLE payements(
>   date_of     date,
>   owner       REFERENCES   workers(id_personal)
> );
>
>
> IT gimme error!!!
> why this isn't right?
> the postgres documentation seem say to do in this manner...

You could try something like this instead:

CREATE TABLE workers(
    id_personal    SERIAL PRIMARY KEY,
    name        VARCHAR(30),
    firstname        VARCHAR(30)
);
CREATE TABLE payements(
    date_of        DATE,
    owner        REFERENCES   workers
);

PRIMARY KEY implies UNIQUE NOT NULL
SERIAL will be an INTEGER DEFAULT nextval('workers_id_personal_seq') so they
get a number automatically.


> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
--
            Robert

pgsql-general by date:

Previous
From: kumar1@home.com (Prasanth A. Kumar)
Date:
Subject: Re: Anyone using ReiserFS in production work? (or advise against it?)
Next
From: Sevo Stille
Date:
Subject: Re: responses to licensing discussion