3 Replies - 818 Views - Last Post: 19 August 2009 - 11:25 AM Rate Topic: -----

#1 tommyflint  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Database Design

Posted 18 August 2009 - 04:46 PM

Hey Guys i was curious on the best way to store the following:

Say i have a form for a movie the user enters the title and then there is a bunch of combo boxes for the genres, of which they can select as many as they wants as a film can be both a comedy and a thriller etc.. any how what is the best way to store the genres they selected?

Cheers,

tommyflint

Edit: this is for a PHP website is that makes any difference

This post has been edited by tommyflint: 18 August 2009 - 04:55 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Database Design

#2 June7  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 104
  • View blog
  • Posts: 904
  • Joined: 09-December 08

Re: Database Design

Posted 18 August 2009 - 06:54 PM

One way would be to have a table with fields for the movie ID and genre. This would be a many to one relationship with the table of movies and allows unlimited categories. The challenge is figuring out best method to get the selections stored in the table. A subform may be the way to go. The other way would be to limit users to maybe 4 genre categories and have four fields in the original table. Not quite according to database design principles but less work to build.

I just noticed you said for PHP website. Sorry, know nothing about web design but suspect the idea of a subform not suitable.

This post has been edited by June7: 18 August 2009 - 07:02 PM

Was This Post Helpful? 1
  • +
  • -

#3 ForcedSterilizationsForAll  Icon User is offline

  • D.I.C Addict

Reputation: 33
  • View blog
  • Posts: 506
  • Joined: 16-July 09

Re: Database Design

Posted 18 August 2009 - 07:22 PM

you could have a movie table, a genre table, then a movie_genre table.

The movie table would be something like:

movieid
movie_title
etc.

The genre table would be:
genreid
genre_name
etc.

The movie_genre table would be:
movie_id
genre_id


This would allow any movie to have as many genre's as you wanted. Then you could populate a listbox or something where the movie table would join the movie_genre table and then join the genre_table to get a list of all your genres.
Was This Post Helpful? 1
  • +
  • -

#4 tommyflint  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Re: Database Design

Posted 19 August 2009 - 11:25 AM

Ahh yess that sounds the way to do it :) cheers guys :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1