Re: problem with table structure

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: Miguel Vaz <pagongski(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: problem with table structure
Date: 2010-07-09 11:25:36
Message-ID: C954B650-50DE-409B-926A-20A3FC0D56B7@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9 Jul 2010, at 3:41, Miguel Vaz wrote:

> and i would like to put these two "sites" in the same data set and maybe add a new table called "site types" to categorize each record (maybe a relation table to allow many to many): how can i go about doing it? is this solution decent enough:
>
> * sites (generic):
>
> id_site
> name
> description
> x
> y
>
>
> * site_natural
> id
> id_site
> altitude
>
> * site_arqueology
> id
> id_site
> id_category
> id_period
>
> But i seem to be missing something. How can i have this in a way that its easy to list only "arqueology sites" for example. I feel the solution is simple enough, even for me, but its eluding me. Any help in the right direction would be very appreciated.

That design seems fine to me. I'd probably put unique constraints on site_natural.id_site and site_arqueology.id_site to fix those into a 1:1 relationship with site.id, otherwise it would allow data with a 1:n relationship - multiple natural or archeological sites at the same location and name.

Another possibility is to use table inheritance, but be aware that some things can't be inherited (foreign key constraints, for example).

BTW, shouldn't that table be named site_archeological? Or if arquelogy is Spanish or Portuguese, shouldn't it be arquelogical?

Alban Hertroys

--
Screwing up is an excellent way to attach something to the ceiling.

!DSPAM:737,4c370742286211218711353!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andras Fabian 2010-07-09 11:48:15 PG_DUMP very slow because of STDOUT ??
Previous Message Miguel Vaz 2010-07-09 10:14:29 Re: problem with table structure