From: M C <m_c_001(at)hotmail(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject:
Date: 2010-02-22 14:06:01
Message-ID: SNT116-W401E14BDA209038FC93DB4F0430@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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
_________________________________________________________________
Send us your Hotmail stories and be featured in our newsletter
http://clk.atdmt.com/UKM/go/195013117/direct/01/

Responses

  • Re: at 2010-02-22 14:16:23 from A. Kretschmer
  • Re: at 2010-02-23 03:41:32 from Jayadevan M

Browse pgsql-novice by date

  From Date Subject
Next Message A. Kretschmer 2010-02-22 14:16:23 Re:
Previous Message Marco Maggi 2010-02-22 13:25:00 which mailing list for bindings writers