Reputation: 5133
I would like to know if it's ok to define a relationship for a column of a table and say it's a foreign key of the same id column from the table.
Example:
Tbl. Name: Categories
Column 1: id
Column 2: name
Column 3: parent_id
Parent_id should contain (only if it's necessary) the id of the category.
I want to make a tree structure of my categories.
Is it ok to do this?
Upvotes: 1
Views: 300
Reputation: 1937
Yes, when it is appropriate. Which it is in the case you describe for a Parent-Child
relation of the same table.
Upvotes: 2