Professional Web Applications Themes

Entering Data Into A Bridge Table (With php?) - PHP Development

I'm new to database design, but I understand the basics of MySQL and php. To make a simple music database in MySQL, I've made a table of songs (song) and a table of players (player) joined by a bridge table (song_play) to allow many-to-many relationships...eg: create table song (song_id int primary key, name char(30)); create table player (player_id int primary key, name char(30)); create table song_play (song_id int not null, player_id int not null, primary key(song_id, player_id)); Once the names of songs and players are entered into their respective tables, is there a way to use php to enter data ...

  1. #1

    Default Entering Data Into A Bridge Table (With php?)

    I'm new to database design, but I understand the basics of MySQL and php.

    To make a simple music database in MySQL, I've made a table of songs
    (song) and a table of
    players (player) joined by a bridge table (song_play) to allow
    many-to-many
    relationships...eg:

    create table song
    (song_id int primary key,
    name char(30));

    create table player
    (player_id int primary key,
    name char(30));

    create table song_play
    (song_id int not null,
    player_id int not null,
    primary key(song_id, player_id));

    Once the names of songs and players are entered into their respective
    tables, is there a way to use php to enter data into the join table other
    than manually looking up the id's from song and player and entering those
    into song_play?

    Thanks,

    Babs

    --
    Using M2, Opera's revolutionary e-mail client: [url]http://www.opera.com/m2/[/url]
    Babs Patel Guest

  2. #2

    Default Re: Entering Data Into A Bridge Table (With php?)

    I noticed that Message-ID: <oprynnxazarz6bv7news.west.cox.net> from
    Babs Patel contained the following:
    >Once the names of songs and players are entered into their respective
    >tables, is there a way to use php to enter data into the join table other
    >than manually looking up the id's from song and player and entering those
    >into song_play?
    Query the database and use the results to populate something like drop
    down boxes. On Submit the selections add a row to the join table.
    However this could get really unweildy with large numbers of
    songs/artists so you have to add some criteria to the initial query.

    In practice though, would you not be doing this when you added new
    songs? Something like:

    Enter song
    insert record into song table
    enter player
    If player exists, display player details
    else prompt to enter player details and then insert record into artist
    table.
    Display player details
    insert record into song_play table

    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs [url]http://www.ckdog.co.uk/rfdmaker/[/url]
    Geoff Berrow Guest

Similar Threads

  1. entering data into MS Access database
    By wwolff in forum Coldfusion Database Access
    Replies: 2
    Last Post: June 14th, 10:45 AM
  2. Calculations and Entering Uncalculated data
    By inzane in forum FileMaker
    Replies: 7
    Last Post: October 10th, 04:24 PM
  3. Entering data, spreadsheet-style
    By Marco Alting in forum ASP
    Replies: 3
    Last Post: August 14th, 10:00 AM
  4. Entering Data and then having another linked data show up.
    By Jennifer Van Pelt in forum Microsoft Access
    Replies: 2
    Last Post: July 16th, 06:15 PM
  5. Entering data on a form?
    By John Vinson in forum Microsoft Access
    Replies: 1
    Last Post: July 1st, 12:50 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139