PDA

View Full Version : many to many realtionships and forms


lux
02-08-2007, 11:53 AM
Hey,

Im building a basketball website.

It will include details of league matches as well as all the other stuff.

I will have a teams table, matches table and a composite table to handle the many to many relation between team and match.

Can anybody point me in the right direction as to how to create insert and update forms to handle the relations. tutorials or suggestions would be greatly appreciated.

Luke

davidj
02-08-2007, 11:57 AM
need to get my head around your process

can you post an example senario

lux
02-08-2007, 12:22 PM
yeah cool:

one website to cater for all the teams in a league

admin tool to create a new match

this will involve 2 teams, one home one away, and a venue and date and time for match.

i will look to use a drop down list to select the teams, pulled from the teams table.

the venue will be another drop down menu, whos values will be derived from the selection made from the home team drop down menu.

the date and time will be standard input/drop down fields.

I want to store this data in a relation db (mysql). As one team can play many matches and a single match will contain more than one team i will need to resolve the many to many relationship by creating a compsite table:

team >- comptable -< match

comptable will comprise of the team id and match id.

i know how to create a form to insert this info but struggle with the logic and code to create a form to update this type of info.

i was wondering whether anyone could explain the login or point me a tutorial

hope that helps

davidj
02-08-2007, 02:39 PM
i would physicaly create your compsite table and the do an insert/update to this table when you set these matches up

this would be then become a live match table not a join table

lux
02-08-2007, 02:50 PM
so i would use the row id, home team and away team cols to create a primary key to ensure no replication.

then only have two tables team and match?

davidj
02-08-2007, 03:01 PM
look at your teams as simply a drop down table

its the match table that will drive the system.

Just pass in the team id into the match table then you could do a dynamic join when you want to display the team data

lux
02-08-2007, 03:02 PM
k cool,

cheers for that