So I have a table of user accounts (Users). There needs to be functionality in place for subaccounts.
So for instance, a company named Dunder Mifflin might have an account. The company will have subaccounts, Accounting and Sales. The Accounting account would have subaccounts for Kevin, Angela, and Oscar. And there's no limit on the number of levels.
My initial idea was to create a table like this:
CREATE TABLE Users
(
UserID INTEGER,
ParentUserID INTEGER,
...
)
Where a primary account's ParentUserID would just be null, but a subaccount would contain the UserID of its parent.
Is this a good design for this? I don't know of any other way.