Re: database design questions

From: Keary Suska <hierophant(at)pcisys(dot)net>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: database design questions
Date: 2006-04-03 16:28:41
Message-ID: C0569B49.27C7B%hierophant@pcisys.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

on 4/3/06 7:38 AM, ottavio(at)campana(dot)vi(dot)it purportedly said:

> 1) The database I'm going to develop is a big list with a catalog of
> items and I want to store subsets of this list representing the
> available items in several places.
>
> My idea is to create the big table with all the elements and then to
> create another table, where each row holds a pair (id_item, id_place)
> and thanks to this create several views, joining the two tables
> and selecting the rows with a give id_place.
>
> Do you think it's too heavy? Is there a simpler way to do it?

On the surface, perhaps. Depending on your implementation details, you may
be adding unnecessary overhead. No one can really say since we don't know
what you are trying to accomplish.

> 2) do you think it's possible in a plpgsql procedure select the name of
> a table into a variable and use that variable in the query?
>
> I mean, can I do something like
>
> SELECT INTO table_name get_table_name();
> SELECT * FROM table_name;

Yes, kind of. I.e., you can probably do what you want but not with the
syntax you are showing. See SELECT INTO and EXECUTE in chapter 36 of the
online docs.

> 3) faq 4.11.1 says
>
>> CREATE TABLE person (
>> id SERIAL,
>> name TEXT
>> );
>>
>> is automatically translated into this:
>>
>> CREATE SEQUENCE person_id_seq;
>> CREATE TABLE person (
>> id INT4 NOT NULL DEFAULT nextval('person_id_seq'),
>> name TEXT
>> );
>
> how can I do it with a INT8 instead of a INT4?

Use BIGSERIAL instead.

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vivek Khera 2006-04-03 16:33:23 Re: pg 8.1.2 performance issue
Previous Message Alex Turner 2006-04-03 16:26:35 Re: database design questions