- Mailing list pgsql-novice

From M C
Subject
Date
Msg-id SNT116-W401E14BDA209038FC93DB4F0430@phx.gbl
Whole thread Raw
Responses Re:  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Re:  (Jayadevan M <Jayadevan.Maymala@ibsplc.com>)
List pgsql-novice
Hi All,

I'm having trouble getting my head round setting up a composite foreign key. For example, consider the following:

CREATE TABLE sensorID (
        SensorID     VARCHAR (30) PRIMARY KEY
);

CREATE TABLE time (
        SensorID  VARCHAR (30) references sensorID(SensorID),
        Time      time without time zone,
        Date      date,
        CONSTRAINT Time_Pkey PRIMARY KEY (SensorID, Time, Date)
);


So far so good. However, I now want to set up another table that uses time.Time_Pkey as its foreign key, but I can't see how to do it. For example, something like:

CREATE TABLE notification (
        Time_Fkey ??????
        FOREIGN KEY (Time_Fkey) references time(Time_Pkey),
        Reason    VARCHAR (30)
);

What needs to go into "??????"  ? Can I even do something like this? Or can I do it with indexes? If so, help please?

Regards,
m

Do you have a story that started on Hotmail? Tell us now

pgsql-novice by date:

Previous
From: Marco Maggi
Date:
Subject: which mailing list for bindings writers
Next
From: "A. Kretschmer"
Date:
Subject: Re: