Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: about primary key

Re: about primary key

From: Phil Bradley <pbradley_at_pacific.net.sg>
Date: Mon, 26 Oct 1998 21:56:10 +0800
Message-ID: <36347F79.AD37E937@pacific.net.sg>

Ray Teale wrote:

> Give example please.
>
> To me this sounds obvious but I'm probably misreading your problem.
>
> EG.
> Table Departments(deptno, deptname);
> Table Employees(empno, empname, deptno);
>
> deptno is primary key of Departments and Foreign Key to employees.

In this example, Employees.deptno is (should be) a foreign key to Departments.deptno.

Whilst there is nothing stopping you having a primary key, which is also a foreign key, e.g.

Table EmployeeStuff(EmpNo, ........)
Table MoreEmployeeStuff(EmpNo, ....)

where EmpNo is both primary key of MoreEmployeeStuff and a foreign key to EmployeeStuff. It always represents either bad database design, optimisation, or a way of getting around an SQL limitation as in an example posted in this thread, where it gets around the fact SQL does not explicitly support sub-types.

Hope this sheds some light.

Phil Bradley Received on Mon Oct 26 1998 - 07:56:10 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US