Re: Theory Question--Two tables relating in more than one way?

From: Hugo Kornelis <hugo_at_pe_NO_rFact.in_SPAM_fo>
Date: Tue, 01 Mar 2005 21:01:27 +0100
Message-ID: <47i921lcqkesht8d7bgvs4l99jeooj6j8i_at_4ax.com>


On 1 Mar 2005 08:25:34 -0800, -CELKO- wrote:

>>> Also, is it a design flaw to have two tables related in more than
>one way? Does it violate TNF? <<
>
>No. But you need to be careful about cycles. I am having a hard time
>coming up with a reasonable example, tho.

Hi Joe,

Wouldn't the classic "employee-worksfor-department / department-ismanagedby-employee" example work?

CREATE TABLE Employees

            (SSN char(9) NOT NULL PRIMARY KEY
            ,FullName varchar(60) NOT NULL
            ,DeptCode char(3) NOT NULL);
CREATE TABLE Departments
            (DeptCode char(3) NOT NULL PRIMARY KEY
            ,DeptName varchar(25) NOT NULL UNIQUE
            ,Manager char(9) NOT NULL REFERENCES Employees(SSN));
ALTER TABLE Employees
  ADD FOREIGN KEY (DeptCode) REFERENCES Departments(DeptCode);

Best, Hugo

-- 

(Remove _NO_ and _SPAM_ to get my e-mail address)
Received on Tue Mar 01 2005 - 21:01:27 CET

Original text of this message