I need to create a database that can allow me to save a persons details, than that person can join two people under his name, and the two need to join 2 people, than the other 2 can join 2 people. This needs to form a hieracy in a way. Than if that person has 15 people under his name, can be moved to another table.
How do I go about creating that database, I have struggled for almost a week trying to think of a solution but nothing has crossed my mind. Any help would be appreciated.
Loading
Sam HobbsPosted May 11, 2011, 8:12 PM
A hierarchy such as that would be used for any manufactured product with minimal complexity. So for example a jet aircraft has many assemblies with many components and many of the components are assemblies. So engineering drawings would need data such as that. Projects such as large software projects have sub-projects that have sub-projects.
Another example is file systems. Disk drive file systems have a root directory with subdirectories and subdirectories have subdirectories.
I think this gives you more terminology for finding artricles and examples and such. Your solution depends on details that you have not made clear. You say "join two people under his name" and you say "if that person has 15 people under his name" so it is not clear if there is a specified number of "joined" people or a limit or whatever. So I can only be vague but what you need is that each person has an id and they have a list of ids of people "joined" to them. The database can have a relationship from the joined ids to the record for each joined person.
There is a potential problem for data such as that. If someone makes a mistake and enters a record in such a manner that it creates an infinite loop of parent and child relationships, then that could cause your program to go into an infinite loop. There are solutions for that problem but unless you fnd an article or sample about that you might spend a very long time thinking about how to solve the problem. I know that the way that a large aircraft manufacturer solved the problem years ago was a tumble-down (recursive or iterative) process that went from the top to the bottom for each path in the product.