I'm trying to make an Addressbook, and one of my features is that you can add a group and add contacts to that group.
Now, my problem is that I'm not sure how do to this. I can make a table called `groups` and add static names like Work, Family, School, etc. But by doing so I don't know how each registered user can choose one of these groups and add it to the list of groups for their personal accounts.
Since i'm using InnoDB I'm referencing each table to the users table with a foreign key.
So I was thinking of doing something like this
contacts table (simplified example)
==========
id
user_id
group
name
address
and in the group column have the data stored like so: {Work, School, Friends}
and somehow do a query that will get each array item and output it so it looks like this kinda
Group
----------------
Work (11)
School (2)
Friends (6)
where the (x) means the number of members in that group.
Question
saiya
I'm trying to make an Addressbook, and one of my features is that you can add a group and add contacts to that group.
Now, my problem is that I'm not sure how do to this. I can make a table called `groups` and add static names like Work, Family, School, etc. But by doing so I don't know how each registered user can choose one of these groups and add it to the list of groups for their personal accounts.
Since i'm using InnoDB I'm referencing each table to the users table with a foreign key.
So I was thinking of doing something like this
contacts table (simplified example)
==========
id
user_id
group
name
address
and in the group column have the data stored like so: {Work, School, Friends}
and somehow do a query that will get each array item and output it so it looks like this kinda
Group
----------------
Work (11)
School (2)
Friends (6)
where the (x) means the number of members in that group.
Link to comment
Share on other sites
16 answers to this question
Recommended Posts