Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: about primary key
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