Figuring out relationships between tables.

From: Andrew Cooper <kairoscreative(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Figuring out relationships between tables.
Date: 2009-08-23 14:47:06
Message-ID: h6rkp6$ilp$1@aioe.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greetings,

This is a general database design question. I've got a database where I
need to hold information on employees. Every employee has much of the
same information so I've created an Employee table. Now, some employees
are supervisors or managers. An employee can only have 1
manager/supervisor but the hierarchy can be varying depths. For example...

I have the following employees:

Bob, Jill, Tom, Bill, Harry, Jane, Amy, Jim, Fred, Sue and June

The management hierarchy works like this:

Bob
/ | \
Jill Tom Bill
/ \ | \
Harry Jane Amy Jim
| |
Fred Sue
|
June

How can I create these relationships in the database? I don't want a
Manager table that duplicates all the information for employees for the
managers. Besides, a manager can have a manager who can have a
manager... and so on. There is probably a simple solution to this
problem but I'm not seeing it. Any help would be appreciated.

Thanks,

Andrew

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2009-08-23 16:02:55 Re: Multiple table entries?
Previous Message Colin Streicher 2009-08-23 14:20:56 Re: bytea corruption?