Re: Multi row sequence?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Filip Wuytack <fwuytack(at)fgscapital(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Multi row sequence?
Date: 2004-12-18 17:51:08
Message-ID: 20041218175108.GA28247@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Dec 18, 2004 at 17:19:27 -0000,
Filip Wuytack <fwuytack(at)fgscapital(dot)com> wrote:
> I'm working on a database that will contain companies (group) and the
> relevant listing (securities-> id) and related periodic information. I want
> the end users of the data to see the relationship between the 2 (comp A,
> security 01, security 02;comp B, security 01, security 02) in the key
> (company,security) as this would for part of the keys in all the other
> related tables (depending if the info is on a company level or security
> level and e.g using the date). By using a normal increment value as unique
> key, I would loose this relation information in key, no?

No. Though from what you are saying here, it doesn't look like you need
that ID at all.
It looks like there should be a company table, a security table and
a company - security table. You haven't said enough about the peridoic
data to suggest how to handle that.
You probably want to use ID columns for the companies and securities,
because there might be companies with the same name (and perhaps securities
as well).
To model this relation you could use the tables below. (In reality you
probably need something more complicated to handle other information.)

create table company (
id serial primary key,
name text not null
);

create table security (
id serial primary key,
name text not null
);

create table compsec (
company int references company(id),
security int references security(id),
primary key (company, security)
);

In response to

Browse pgsql-general by date

  From Date Subject
Next Message v.demartino2 2004-12-18 18:26:48 Make a query faster...
Previous Message Filip Wuytack 2004-12-18 17:19:27 Re: Multi row sequence?