storing list in cell of a mysql table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
suthie
Forum Commoner
Posts: 68
Joined: Sat Jun 09, 2007 10:46 am

storing list in cell of a mysql table

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

This is a really broad question. What have you done so far?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
suthie
Forum Commoner
Posts: 68
Joined: Sat Jun 09, 2007 10:46 am

Post 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?
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
xpgeek
Forum Contributor
Posts: 146
Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:

Post 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.
Post Reply