I have to implement a unary relationship that works in this way:
There is an entity, called Employee and every Employee can be managed by another Employee until the boss which is not managed by anyone.
I tried this query:
CREATE TABLE employee
(id INTEGER PRIMARY KEY,
name VARCHAR(40) NOT NULL,
managed_by INTEGER REFERENCES employee);
But does not work because, I think, in SQL a Foreign Key cannot reference its own entity.
How can I represent this recursive relationship in a correct way?