0

I want to create a tournament application with cakePHP and I need some help to create Database and linking Models correctly.

My ultimate goal is :

- add/edit/delete teams (i dont need list of players)
- add/edit/delete matchs with 2 teams per match
- display a list of match with results (ex:  match5 : TeamAname **2** vs **0** TeamBname)

I dont really know how to organise models and sql tables, for the moment i see 2 tables :

- teams
- matches

Did i need another table between the two tables (ex: matches_teams) or i can use teamA_id and teamB_id in my matches table ? Does CakePHP support multiple foreign keys in same model ?

I want to know if someone has already developed this kind of project in cakePHP, and if it work fine and logically (without tricks).

Thanks!

kesm0
  • 847
  • 1
  • 11
  • 20

1 Answers1

0

*> Do i need another table between the two tables (ex: matches_teams) or i can use teamA_id and teamB_id in my matches table?*

You don't need another (association) table, because the only associations you have are the two many-to-one associations between matches and teams given by the two reference columns teamA_id and teamB_id of matches.

In terms of the ontological semantics of the domain of sports, the entity type Match represents an event type, while the entity type Team represents an object type. And for each event of type Match you have two objects of type Team participating in it.

> Does CakePHP support multiple foreign keys in same model?

It would be quite limited if it wouldn't.

Gerd Wagner
  • 5,481
  • 1
  • 22
  • 41