views:

47

answers:

1

I'm attempting to build a web app and I've run into a bit of a wall. I'm not asking for anyone to hold my hand through making this, just some advice and a push in the right direction.

So, I'm trying to build an app that uses the Google Maps API to display a map of local parks near you and allow people to post pickup games (informal sporting events) for a specific time at a specific park. Simple enough right?

So far I've created a database with a table of local parks (columns: name, longitude, latitude) and a php script that takes that table and turns it into an XML file that the map uses to plot the points of the parks. I've also created a form that uses php to insert new data into the table and thus create a new park marker on the map.

This has all gone well so far but I'm just not sure how to proceed. I think I want to create a table 'games' (columns: sport, time, park(?)) but I'm not sure if that will work. Will I be able to setup a relationship between the 'parks' and 'games' table so that many games belong to a park? If so, how would I map those games? Does my thinking make sense?

+1  A: 

If you'll create games table with sport_id | time | park_id columns, then game entity will be related to park entity by one-to-many relation. It means that one park handles 0..Many games and one game always belongs to one park.

So, this is suitable solution for your issue. It fits your expectations.

Additional info about relations: Cardinality

zerkms
So MySQL creates the relationship automatically when _id is appended?
585connor
Or would I have to manually create a relation between the id column on parks and the park_id column of games? If so, any good resources to learn more on how?
585connor
Nope, mysql does not create relation automatically. To keep integrity you have to manually create foreign keys constraint: http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
zerkms