Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Advice on Table Structure

Status
Not open for further replies.

silicontoadet

Programmer
Jan 7, 2009
3
GB
Hi,

I'm new to mysql and databases in general, I've created two tables, one for "user" and one for "tracks" lets say:

user(userID, name, email)

track(trackID, name)

Let's say I have 100 users and each user buy's 1000 tracks, at the moment my user table is like so:

user(userID, name, email, tracks)

where tracks is a comma separated list of id's. Something just doesn't feel right about this, any suggestions for the best approach on this.

Thanks

Toad
 
yes never store comma separated lists. do a search on DATABASE NORMALIZATION so you understand the concept.

You need three tables, the first two you have user and track at the top of your post.

you then have another

usertracks
userid, trackid

and store a new row for each track a user owns.

you then join the three tables to output the tracks each user owns.
 
Thanks guelphdad - very helpful,

Thanks johnwm - will have a read
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top