Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f02JEdL02653 for ; Tue, 2 Jan 2001 14:14:39 -0500 (EST) (envelope-from pgsql-admin-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f02FcpL85447 for ; Tue, 2 Jan 2001 10:38:51 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.9.3/8.9.3) id KAA48985 for pgsql-admin@postgresql.org; Tue, 2 Jan 2001 10:35:45 -0500 (EST) (envelope-from news) X-Authentication-Warning: news.tht.net: news set sender to using -f From: "Scott Goodwin" X-Newsgroups: comp.databases.postgresql.admin Subject: Automatic typing of foreign keys when creating tables Date: Tue, 2 Jan 2001 09:35:21 -0600 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 55 Message-ID: <92ssgf$1fql$1@news.tht.net> Reply-To: "Scott Goodwin" X-Trace: news.tht.net 978449745 48981 129.61.146.23 (2 Jan 2001 15:35:45 GMT) X-Complaints-To: scrappy@hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 To: pgsql-admin@postgresql.org X-Archive-Number: 200101/8 X-Sequence-Number: 378 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.