Jump to content

Beginner looking for Advice


criostage

Recommended Posts

Hi, i m doing a small project of mine to learn PHP and MySQL as a hobby, i did some PHP scripts or utilities in the past but never had actually to use an database until now (i only have some experience in creating databases, tables and perform backups and restores on the database), in this project i m trying to do an TV Show database to store and keep track of what i have.  I started to write down what i needed to know about an certain show and i came to this list:

 

- Name, Alternative Name, Genre, Relation with other series or seasons, description, number of episodes etc ...

 

and would translate into something like this in tables:

 

ID | Name | AlName | Relation | Description | Episodes | Genre

 

So Far so good, inserting just 1 data field from php to the database isnt that hard, but then since i watch Japanese, Korean and sometimes chinese movies there are a few genre's (especially in japanese Anime) that i would like to store an small description to the term to know what it means so i had to do an 2nd table just for the Genre's (this would help me to insert more genre's to the database later on as well) so the database would be like this:

 

TV Show Table

ID | Name | AlName | Relation | Description | Episodes

 

Genre Table

ID | Genre | Description

 

My Question is (and sorry for long description ...) whats the best way to store in the database the relation between the 2 tables to say that the TV Show With the ID 10 have the Genre ID 10, 12 and 13? thank you in advance.

 

PS: i dont have any SQL code to show yet since all my "drawing" are all still on paper ... truly sorry about that but if needed i will do the code with what ever i already have.

Link to comment
Share on other sites

whats the best way to store in the database the relation between the 2 tables to say that the TV Show With the ID 10 have the Genre ID 10, 12 and 13?

Use another table.

tvshow | genre
-------+------
    10 |    10
    10 |    12
    10 |    13

Link to comment
Share on other sites

whats the best way to store in the database the relation between the 2 tables to say that the TV Show With the ID 10 have the Genre ID 10, 12 and 13?

Use another table.

tvshow | genre
-------+------
    10 |    10
    10 |    12
    10 |    13

 

lol damn the solution was pretty simple ... tyvm for your help man =)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.