I'm fairly new to MySQL and I need help with a relatively basic question.
Say I have an auto-increment table that lists individual people by row. I include all of the basic information about each person such as name, age, race, etc in the columns. But say I want to include lists of the people's friends as well. Since these lists would be dynamic and to my knowledge you cannot have two auto-increment variables in a single table, it would not be possible to include the friends lists in that specific table as there are no such things as sub-tables or anything of the sort in MySQL (again to the best of my knowledge). If you wanted dynamic friends lists you would have to make a new table solely dedicated to that purpose.
Am I right in this thinking? Or am I missing something?
Here is my current general idea (which I rather dislike):
table people_list {
person_id (auto-increment)
name
age
race
...
}
table friends_lists {
friendship_id (auto-increment)
person_id1
person_id2
}
Note that I just made up the syntax in essence of MySQL for demonstration.
Is there any better way?
friends_listsis usually called an "association table" and is the standard SQL approach for this sort of thing.