From: Scott Goodwin <scott@scottg.net>
To: pgsql-admin@postgresql.org
Subject: Automatic typing of foreign keys when creating tables
Date: Tue, 2 Jan 2001 09:35:21 -0600
Message-ID: <92ssgf$1fql$1@news.tht.net> (raw)
This is really a suggestion rather than a question:
I've noticed that Oracle allows you to not declare the type of column if the
column is a foreign key and the primary key has already been declared in
another table.
Though not a critical feature, I think it would be great if PostgreSQL could
do this; it would save time during development as you wouldn't have to find
and change all of the foreign key type declarations to match the primary key
type every time you decided to change the primary key type.
The first piece shows the PostgreSQL way, where object_type is declared as
an integer. The second shows how object_type is not declared as an integer
or any other type.
===================== PostgreSQL
create table itk_object_types (
object_type integer primary key
);
create table itk_objects (
object_id integer not null
constraint itk_objects_pk primary key,
object_type integer not null
constraint itk_objects_object_type_fk
references itk_object_types(object_type)
);
===================== Oracle
create table itk_object_types (
object_type integer primary key
);
create table itk_objects (
object_id integer not null
constraint itk_objects_pk primary key,
object_type not null
constraint itk_objects_object_type_fk
references itk_object_types(object_type)
);
/s.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: scott@scottg.net
Subject: Re: Automatic typing of foreign keys when creating tables
In-Reply-To: <92ssgf$1fql$1@news.tht.net>
References: <92ssgf$1fql$1@news.tht.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox