From jkanter@virginia.edu Mon Aug 5 13:01:04 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 23FD1475481 for ; Mon, 5 Aug 2002 09:01:04 -0400 (EDT) Received: from mail.virginia.edu (mail.Virginia.EDU [128.143.2.9]) by postgresql.org (Postfix) with SMTP id A6BF5475154 for ; Mon, 5 Aug 2002 09:00:58 -0400 (EDT) Received: from smtp.mail.virginia.edu by mail.virginia.edu id aa07441; 5 Aug 2002 9:00 EDT Received: from jlk3xpc (d-128-19-222.bootp.Virginia.EDU [128.143.19.222]) by smtp.mail.Virginia.EDU (8.9.3/8.9.3) with SMTP id JAA31198 for ; Mon, 5 Aug 2002 09:00:56 -0400 Message-ID: <006c01c23c80$345855c0$de138f80@virginia.edu> From: Jodi Kanter To: Postgres Admin List Subject: lookup tables Date: Mon, 5 Aug 2002 09:01:24 -0400 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0069_01C23C5E.ACE36010" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/15 X-Sequence-Number: 5130 This is a multi-part message in MIME format. ------=_NextPart_000_0069_01C23C5E.ACE36010 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable The postgres book that I am referencing states that lookup tables do not ne= ed to be related to other tables. They exist just for use by the applicatio= n to give the user a list of choices. Wouldn't it be better to include foreign keys to their corresponding tables= ? Or to merely link them via the string value so they can be joined? Any opinions? I am working on a database that has some lookup tables that are joined by f= oreign keys and others that are just joined by the "type" field. For exampl= e, a "contact" table has a field known as "contacttype." There is a "contac= ttype" table with only one field in called "type." The "contacttype" field = in the CONTACT table and the "type" field in CONTACTTYPE table are the sam= e. They can be joined if I want to access the description information in th= e "desc" field in the CONTACTTYPE table. Please let me know if anyone sees any issues in doing it this way? Are both= methods valid and efficient ways to handle this? Thanks Jodi _______________________________ Jodi L Kanter BioInformatics Database Administrator University of Virginia (434) 924-2846 jkanter@virginia.edu =20 =20 =20 ------=_NextPart_000_0069_01C23C5E.ACE36010 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
The postgres book that I am referencing= states=20 that lookup tables do not need to be related to other tables. They exist ju= st=20 for use by the application to give the user a list of choices.
Wouldn't it be better to include foreig= n keys=20 to their corresponding tables? Or to merely link them via the string value = so=20 they can be joined?
Any opinions?
I am working on a database that has som= e=20 lookup tables that are joined by foreign keys and others that are just join= ed by=20 the "type" field. For example, a "contact" table has a field known as=20 "contacttype." There is a "contacttype" table with only one field in called= =20 "type." The "contacttype" field in the CONTACT table and the "type" f= ield=20 in CONTACTTYPE table are the same. They can be joined if I want to acc= ess=20 the description information in the "desc" field in the CONTACTTYPE=20 table.
Please let me know if anyone sees any i= ssues=20 in doing it this way? Are both methods valid and efficient ways to handle= =20 this?
Thanks
Jodi

_______________________________
Jodi=20 L Kanter
BioInformatics Database Administrator
University of=20 Virginia
(434) 924-2846
jkanter@virginia.edu

 

 

 

<= /DIV> ------=_NextPart_000_0069_01C23C5E.ACE36010-- From marcm@eisolution.com Mon Aug 5 13:55:36 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EFECA475CE3 for ; Mon, 5 Aug 2002 09:55:36 -0400 (EDT) Received: from dg.eisolution.com (dsl-232-15.speedsite.com [206.126.232.15]) by postgresql.org (Postfix) with ESMTP id 3C607475CDC for ; Mon, 5 Aug 2002 09:55:36 -0400 (EDT) Received: from marcmdelltop (dg101.eisolution.com [10.5.1.101]) (authenticated) by dg.eisolution.com (8.11.6/8.11.6) with ESMTP id g75DxtL10601; Mon, 5 Aug 2002 08:59:55 -0500 Message-ID: <000701c23c89$7607bd40$6501050a@eisolution.com> From: "Marc Mitchell" To: "Jodi Kanter" , "Postgres Admin List" References: <006c01c23c80$345855c0$de138f80@virginia.edu> Subject: Re: lookup tables Date: Mon, 5 Aug 2002 09:07:40 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/17 X-Sequence-Number: 5132 Jodi, A common model within the databases of many of our applications is to have a "codes" table for providing "lookup" values for columns of ANY table. This allows you to deploy a single set of routines on the front end to getting, listing and validating fields against the code-ified list of values. The joining columns of this codes table are field name and table reference. Entries' fundamental attributes are the code itself, a short description, a long description and a usage note. Joining to this codes table is always an option and often done in reports were the value stored in the main table is merely the coded value but the short or long description is desired on the report itself. As for setting up actual foreign key references, we don't normally do that but, admittedly, that's more due to apathy than design. The real value in doing so would be the ability to enforce validation of these code-ified values at a database level rather than the application level. To easily do so, you'd probably want to add a single field primary key to the codes table since, without one, the primary key is the composite of code and table reference and putting the latter column into the foreign key reference tables seems to me redundant. You could also hand craft your constraints with triggers and procedures. Hope this is useful. Marc ----- Original Message ----- From: "Jodi Kanter" To: "Postgres Admin List" Sent: Monday, August 05, 2002 8:01 AM Subject: [ADMIN] lookup tables The postgres book that I am referencing states that lookup tables do not need to be related to other tables. They exist just for use by the application to give the user a list of choices. Wouldn't it be better to include foreign keys to their corresponding tables? Or to merely link them via the string value so they can be joined? Any opinions? I am working on a database that has some lookup tables that are joined by foreign keys and others that are just joined by the "type" field. For example, a "contact" table has a field known as "contacttype." There is a "contacttype" table with only one field in called "type." The "contacttype" field in the CONTACT table and the "type" field in CONTACTTYPE table are the same. They can be joined if I want to access the description information in the "desc" field in the CONTACTTYPE table. Please let me know if anyone sees any issues in doing it this way? Are both methods valid and efficient ways to handle this? Thanks Jodi _______________________________ Jodi L Kanter BioInformatics Database Administrator University of Virginia (434) 924-2846 jkanter@virginia.edu