I have a table which has a “foreign key” referencing itself. This would be very useful, except I am uncertain how to add the first record to such a table. No matter what I add, I cannot provide a valid “foreign” key to the table itself, having no entries yet. Maybe I’m not going about this correctly, but I want this table to represent something that is always a member of itself. Is there a way to “bootstrap” such a table, or another way to go about self-reference?
Share
One option is to make your field
NULL-able, and set the root record’s parent key toNULL:Otherwise you could still use a
NOT NULLparent key and point it to the root record itself: