theredwino Posted May 5, 2010 Share Posted May 5, 2010 i'm working on a CMS project in PHP/MySQL that includes a 'users' table--a list of clients and their contact info. Recently, the client i'm building this for asked me to include a feature wherein an 'executor' client profile could have 'child' accounts. For instance, if a client wanted to place his wife and kids 'under his account', an admin could simply open his profile and drag and drop client names from the 'All Clients' list into a box on his profile. This way, when his profile is opened, these accounts and their contact data, etc. would be listed below his. Now, i know what i'm doing when it comes to building most of this. In fact, most of it's already built. My question is: What is the best method for storing the 'child' account indexes in a MySQL field? The client profile information is already there, stored in the 'users' table. What [i think] i need to do is add a 'children' column to the 'users' table and populate it with the child client id's. The problem is, i'm not sure what the best/most efficient field type is to use. i was planning on using SET, but that doesn't work because any given 'executor' client could have anywhere from 1 to an indefinite number of 'child' accounts associated with it. This seems (theoretically at least) to be a pretty easy problem to solve...i'm just not sure how. If anybody has any advice for me, thank you very much in advance! Link to comment https://forums.phpfreaks.com/topic/200835-users-table-with-child-accounts/ Share on other sites More sharing options...
Muddy_Funster Posted May 5, 2010 Share Posted May 5, 2010 Reverse your principle. Make a new column and call it "Parent"...assign the single executor ID to each of the children rather than multiple child ID's to the executor. Link to comment https://forums.phpfreaks.com/topic/200835-users-table-with-child-accounts/#findComment-1053834 Share on other sites More sharing options...
theredwino Posted May 5, 2010 Author Share Posted May 5, 2010 That's it! i don't know why that solution wasn't immediately apparent to me... Thank you! Link to comment https://forums.phpfreaks.com/topic/200835-users-table-with-child-accounts/#findComment-1053844 Share on other sites More sharing options...
Muddy_Funster Posted May 5, 2010 Share Posted May 5, 2010 Your welcome and it's often easy to over complicate things in cases like this (unless your simple like me ) Link to comment https://forums.phpfreaks.com/topic/200835-users-table-with-child-accounts/#findComment-1053847 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.