Question

I'm creating a MySQL database about FIFA's World Cup, i have the "team" and "player" tables, i need to create in "team" table a column (ArrayList like Java) of "player" objects, but i dont know how i can do that, i need help please.

I created in "team" a Foreing Key referenced "player" table, but i need more than 1 player. I need to create 22 foreing keys in "team" for all the players?

http://i.gyazo.com/645b723e49ef1eba46ac0487825035b4.png

Thanks!

Was it helpful?

Solution

If i understand you correctly try this:

Make a table "Team" with id_team as a primary key Make a table "player" with id_player as a primary key set id_team as a foreign key in table Player

that way you can select all players who have id_team == lets say 5

select * from Player where id_team = 5

here is the database model if it helps: model

It is not recommended to store whole objects into Mysql databases afaik, you should consider storing just a simple data like players name, players age etc. Then after selecting those data, rebuild those object from selected values. But if you insist on storing objects here is thread : How do I store an php object in a MySQL table?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top