Page 1 of 1

storing list in cell of a mysql table

Posted: Thu Aug 23, 2007 7:27 pm
by suthie
Hey I am trying to do a thing that lets users sign up for info about different topics and stuff, and I want them to be able to click a button to get their name on a list. Like a facebook group. I also need to be able to find individual users from these lists (using the mysql select from table where...)

How can this be done?

Posted: Thu Aug 23, 2007 10:47 pm
by John Cartwright
This is a really broad question. What have you done so far?

Posted: Fri Aug 24, 2007 10:17 am
by feyd
I certainly wouldn't use a "single cell" .. What you are looking for is often referred to as a linking table. It links one table to another in a many-to-many relationship.

Posted: Sat Aug 25, 2007 4:06 pm
by suthie
It seems to me a separate table would be a little more than i need....

To be more specific on what I want:
Each user will be able to post a bit about whats going on with him. People will be able to click to put their name on a list so that he email an update to all those people when something changes.

Maybe I'm wrong, but why would I need a table for that? Heres what my userdata table looks like

Userid | Username | Password | Email | Subscribers

is it not possible to store a list (array?) in the subscribers cell?

Posted: Sat Aug 25, 2007 5:10 pm
by kaszu
You can by using serialize function, but i agree with feyd, separate table would be better.
Why you would need it? What if you will want later to add possibility for user to see to what he has subscribed to?

Posted: Sun Aug 26, 2007 3:02 am
by feyd
The major problems with a solution where the data is stored in a single record are searching and capacity. You will have a finite number of references the field may hold. As the reference numbers reach higher numbers of digits you will accordingly shrink the number of possible references a user may have. Do you find that fair to those users? No. Searching this data and thereby altering it will become far more of a nightmare than a normalized table solution.

Posted: Sun Aug 26, 2007 4:14 am
by xpgeek
2 suthie It's Bad idea.

You need to grow you table vertically not gorizontally.

Store you data in separate table - you nomalize table structure - it's best practice.