[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] Questions re database schema - normalization

From: Horst Herb
Subject: Re: [Gnumed-devel] Questions re database schema - normalization
Date: Fri, 3 Sep 2004 18:04:26 +1000
User-agent: KMail/1.6.2

On Fri, 3 Sep 2004 01:44, J Busser wrote:
> Does this mean that
>     if a join should have to operate on 2 tables
>     selecting from each a field named "id"
> that the syntax will stumble, and/or it is unwanted/extra work to
> have to provide aliases so as to be able to distinguish the column
> names and data from the two "id" fields in the output?

create table a(id serial primary key, text text);
create table b(id serial primary key, id_a integer references a(id), text 

select a.text, b.text from a left join b on (;

That works. Where's the problem? Whenever there is a identifier clash, all you 
have to do is explicitly name the table (unless you use aliases)

Regarding the id vs fk debate:

I recommend that 
- any primary key of a table is named "id"
- any reference to a foreign key is named id_<tablename>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]