FORIEGN KEY's, JOIN's, and others

Поиск
Список
Период
Сортировка
От Nikos Mouat
Тема FORIEGN KEY's, JOIN's, and others
Дата
Msg-id Pine.C=64.4.21.9911240950150.25693-100000@rapture.cyberflunk.com
обсуждение исходный текст
Ответ на ANNOUNCE UdmSearch-2.1.6  (Alexander Barkov <bar@izhcom.ru>)
Список pgsql-general
Hi,
   I've been using Postgres for a while for pretty simple schemas.
I'm now trying to clean things up, and start enforcing data integrity at
the SQL level, rather than the application level. I'm now running into the
following:

NOTICE:  CREATE TABLE/FOREIGN KEY clause ignored; not yet implemented
ERROR:  JOIN expressions are not yet implemented

Is there a time frame for the addition of these features?
I frequently use OID's to reference entries in other tables, for instance:

CREATE TABLE speeds (
   speed        varchar
);

CREATE TABLE plans (
   name         varchar,
   def_speed    oid,
   def_price    money
);

now plans.def_speed is simply the oid in speeds. How can I make sure that
when an INSERT is done into plans, the value in def_speed is really an oid
in speeds? How can I stop users from deleting an entry in speeds when that
OID is used in plans.def_speed?

Is there some way to do this that I don't know about? (which I assume to
be likely) - Is REFERENCES or FOREIGN KEY the answer that I'm looking for?

Also, is there a way to create sub tables, ie, something like:

CREATE TABLE cust_notes (
   note_date    date,
   added_by    oid,
   note        varchar
);

CREATE TABLE customers (
   customer_name    varchar,
   notes        table cust_notes
);

and then allow me to somehow do:

select note_date,added_by,note from customers.notes where customers.oid =
12345;

I currently do this by doing:

CREATE TABLE cust_notes (
   note_date    date,
   added_by     oid,
   note         varchar,
   customer_id  oid
);

CREATE TABLE customers (
   customer_name        varchar,
);

select note_date,added_by,note from cust_notes where customer_id = 12345;

but it seems somehow more logical the other way.

Thanks
nm



В списке pgsql-general по дате отправления:

Предыдущее
От: "Santiago Martin-Pascual"
Дата:
Сообщение: Help on PL/PGSQL
Следующее
От: Bruce Lowery
Дата:
Сообщение: deadlock in 6.4.2