score:1

Accepted answer

Usually you don't create one table with a column for category for these very reasons, that you can't have proper foreign keys.

You should create several tables.

One table to link Bills and GeneralArticles. Second table to link Bills and CalculatedArticles. Third table to link Bills and AdditionalRecords.

For the first link it may look like this (I didn't check the syntax):

CREATE TABLE BillsGeneralArticlesAssosiations(
[B_ID] [int] NOT NULL FOREIGN KEY REFERENCES Bill (B_ID) ,
[GA_ID] [int] NOT NULL FOREIGN KEY REFERENCES GeneralArticles (GA_ID)
CONSTRAINT [PK_BillsGeneralArticlesAssosiations] PRIMARY KEY CLUSTERED 
(
    [B_ID] ASC,
    [GA_ID] ASC
))

Sometimes I add an IDENTITY column ID to this table as a primary key. Especially if there are other fields in this linking table.


More questions

More questions with similar tag