Re: [GENERAL] Schema design / joins - Mailing list pgsql-sql

From silly sad
Subject Re: [GENERAL] Schema design / joins
Date
Msg-id 4BE00D75.30204@bankir.ru
Whole thread Raw
In response to [GENERAL] Schema design / joins  (E H <edgeofmyhand@gmail.com>)
List pgsql-sql
> __Orgs__
>   id
>   name
>
> __Seasons__
>   id
>   org_id  fk(orgs.id)
>   name
>
> __Teams__
>   id
>   season_id  fk(seasons.id)
>   name
>
> __TeamFees__
>   id
>   team_id  fk(teams.id)
>   *org_id<--- (?put extra fk here to avoid many joins?)

NO.

instead of it
use triggers before insert/update

CREATE FUNCTION foo() RETURNS TRIGGER AS $$
BEGIN  SELECT org_id INTO new.org_id FROM __seasons__ WHERE id=new.season_id;
END;
$$ LANGUAGE plpgsql;

et cetera.

AND now other way lead you to the future.


pgsql-sql by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: WAL-files restore and nextval('PK')
Next
From: "David Weilers"
Date:
Subject: Foreign key constraint referencing a parent table