From: | Chris Withers <chris(at)simplistix(dot)co(dot)uk> |
---|---|
To: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | foreign key to "some rows" of a second table |
Date: | 2016-02-22 11:03:56 |
Message-ID: | 56CAEB1C.8030102@simplistix.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi All,<br>
<br>
So, I have a table that looks like this:<br>
<br>
<meta charset="utf-8">
CREATE TABLE config (<br>
region varchar(10),<br>
name varchar(10),<br>
value varchar(40)<br>
);<br>
<br>
Another looks like this:<br>
<br>
CREATE TABLE tag (<br>
host varchar(10),<br>
type varchar(10),<br>
value varchar(10)<br>
);<br>
<br>
What's the best way to set up a constraint on the 'config' table
such that the 'region' column can only contain values that exist in
the 'tag' table's value column where the 'type' is 'region'?<br>
<br>
cheers,<br>
<br>
Chris<br>
</body>
</html>
Attachment | Content-Type | Size |
---|---|---|
unknown_filename | text/html | 899 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Achilleas Mantzios | 2016-02-22 11:27:23 | Re: foreign key to "some rows" of a second table |
Previous Message | Dave Cramer | 2016-02-22 10:26:47 | Re: JDBC behaviour |