Best datastructure for this relationship...
Posted
by Travis
on Stack Overflow
See other posts from Stack Overflow
or by Travis
Published on 2010-06-11T14:28:07Z
Indexed on
2010/06/11
14:32 UTC
Read the original article
Hit count: 218
I have a question about database 'style'.
I need a method of storing user accounts. Some users "own" other user accounts (sub-accounts). However not all user accounts are owned, just some.
Is it best to represent this using a table structure like so...
TABLE accounts (
ID
ownerID -> ID
name
)
...even though there will be some NULL values in the ownerID column for accounts that do not have an owner.
Or would it be stylistically preferable to have two tables, like so.
TABLE accounts (
ID
name
)
TABLE ownedAccounts (
accountID -> accounts(ID)
ownerID -> accounts(ID)
)
Thanks for the advice.
© Stack Overflow or respective owner