Skip to main content

TagsParentTags Table

Description: Associative table for self-referential many-to-many relationships among tags (for hierarchical tagging).

Table Definition:

CREATE TABLE TagsParentTags (
tagId INT NOT NULL,
parentTagId INT NOT NULL,
PRIMARY KEY (tagId, parentTagId),
FOREIGN KEY (tagId) REFERENCES Tags(id),
FOREIGN KEY (parentTagId) REFERENCES Tags(id)
);

Fields:

Field NameData TypeNullabilityConstraintsDescription
tagIdINTNOT NULLPRIMARY KEY, FOREIGN KEYChild tag ID (references Tags(id)).
parentTagIdINTNOT NULLPRIMARY KEY, FOREIGN KEYParent tag ID (references Tags(id)).