I have a DB schema from The Data Model Resource Book, Vol. 1. In it is a table like this:
CREATE TABLE [dbo].[AccountingPeriod](
[AccountingPeriodID] [int] NOT NULL,
[RoleTypeID] [int] NOT NULL,
[PeriodTypeID] [int] NOT NULL,
[AcctgPeriodNum] [int] NOT NULL,
[FromDate] [smalldatetime] NOT NULL,
[ThruDate] [smalldatetime] NOT NULL,
[PartyID] [int] NOT NULL,
PRIMARY KEY CLUSTERED (
[AccountingPeriodID] ASC)
With a constraint defined as:
ALTER TABLE [dbo].[AccountingPeriod] WITH CHECK ADD FOREIGN KEY([AccountingPeriodID])
REFERENCES [dbo].[AccountingPeriod] ([AccountingPeriodID])
The AccountingPeriodID column has a self referencing foreign key that the text claims is a recursive reference column but I think it’s an error. I think I need another column to properly store recursive references in this table. Can the author’s method be implemented with the table definition supplied, why?
Yes, You need another column which will reference the primary key column of the table itself, for self referencing a table. Self referencing column really does not make any sense.