I have four tables
create table entities{ integer id; string name; } create table users{ integer id;//fk to entities string email; } create table groups{ i
If you want a truly theoretically infinite level of nesting, then recursion is the only option, which precludes any sane version of SQL. If you're willing to limit it, then there are a number of other options.
Check out this question.