Syntax error needs fresh eyeballs

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Syntax error needs fresh eyeballs
Date: 2016-12-26 23:23:29
Message-ID: alpine.LNX.2.11.1612261520040.25972@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

My schema includes three tables and psql throws an error I'm not seeing
when I try to read the schema into the database. I'd appreciate fresh eyes
looking at the table and learning what error I'm not seeing.

The tables:

CREATE TABLE Weather (
site_id INTEGER PRIMARY KEY,
site_name TEXT,
site_location TEXT
);

CREATE TABLE Weather_Params (
site_id INTEGER
REFERENCES Weather(site_id),
param TEXT,
param_unit TEXT,
freq INTEGER,
freq_unit TEXT,
equip TEXT,
PRIMARY KEY (site_id, param)
);

CREATE TABLE Weather_Data (
site_id INTEGER
REFERENCES Weather(site_id),
monit_date DATE,
monit_time TIME,
read_by TEXT, -- name of employee collecting data
param TEXT
REFERENCES Weather_Params(param),
param_value REAL,
PRIMARY KEY (site_id, monit_date, monit_time, param)
);

The error:

ERROR: there is no unique constraint matching given keys for referenced
table "weather_params".

TIA,

Rich

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2016-12-26 23:37:10 Re: Syntax error needs fresh eyeballs
Previous Message Арсен Арутюнян 2016-12-26 20:55:58 Indexes and loops or some kind of pg error?