Entering Data Into A Bridge Table (With php?)

This is a discussion on Entering Data Into A Bridge Table (With php?) within the PHP Language forums, part of the PHP Programming Forums category; I'm new to database design, but I understand the basics of MySQL and php. To make a simple music ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-15-2003
Babs Patel
 
Posts: n/a
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: http://www.opera.com/m2/
Reply With Quote
  #2 (permalink)  
Old 11-15-2003
Geoff Berrow
 
Posts: n/a
Default Re: Entering Data Into A Bridge Table (With php?)

I noticed that Message-ID: <oprynnxazarz6bv7@news.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 http://www.ckdog.co.uk/rfdmaker/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:12 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0