Jump to content


Photo

MYSQL Table Structure


  • Please log in to reply
3 replies to this topic

#1 jaymc

jaymc
  • Members
  • PipPipPip
  • Advanced Member
  • 1,521 posts
  • LocationLiverpool

Posted 21 September 2006 - 10:00 AM

Ok, I am making a music website.

Each song info will be stored in a database, I am thinking of using the following fields for the songs table

[ID] [GENRE] [ARTIST FULL NAME] [ALBUM NAME] [SONG NAME] [ALBUM ID] [VIEWS]

Now their is going to be about 300 albums, so if their are 15 songs per album then thats 4500 rows in the table

The query will be pretty straiight forward when someone wants to listen to a song, it will be selected by ID which will be unique

Anyway, Im just wondering, is this the best way to go about it. Chuck every song in the same table?
I would love to change the world, but they won't give me the source code

SEO Agency

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 21 September 2006 - 11:08 AM

If that's the full extent of your design, then that's fine.  If 'next week' you decide to have artist bio information you might want to modify the design now to two tables with the one you describe using an artist_id that points to a record in the artist_bio table where the artist's detailed information exists.
Legend has it that reading the manual never killed anyone.
My site

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 21 September 2006 - 01:27 PM

Well, IMHO, songs have views and names, and nothing else -- you should pull out artist & genre into another table, and just link them with a FK.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 ryan.od

ryan.od
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 24 September 2006 - 08:40 PM

You should look into database normalization (search it) and break this table into multiple tables.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users