If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Movie database structure

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-11-10, 15:52
04johnsk 04johnsk is offline
Registered User
 
Join Date: Mar 2010
Posts: 1
Movie database structure

Hello,
having just started learning php and MySQL I've decided to set myself the task of designing a movie website(kind of a similar idea to imdb).

I want users to be able to view films by category, however I want one movie to be able to have several categories.

My question is, how should I go about choosing my tables?


My initial idea is to have seperate tables for Movie and Genre and have a field for genre in table Movie allowing multiple genres seperated by commas. In doing this I would have to presumably extract information using the php "explode" function to split the string into an array.

Thanks
Reply With Quote
  #2 (permalink)  
Old 03-11-10, 16:05
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,308
A much better idea would be to create a linking table, that has foreign keys to both the Movie and the Genre table (and those foreign keys combined can be its primary key). You can also include any additional information about the relationship such as the date it was created, the date (if any) it was invalidated, who created it, etc.

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On