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