Richard Downs Richard Downs - 1 year ago 63
MySQL Question

Is this the correct database structure for a sports team based database featuring countries and divisions?

I am looking to build a sports database where the user selects a country from a list 15 different countries, that then presents different divisions within that country. The user then selects a division and is presented with a list of teams within that division to select.

One approach I had been advised to take is to have separate tables for Countries and Teams.

Table - Countries

Country | Teams (int array)

Table - Teams

ID (int) | Team Name | Division

The 'Teams (int array) would match with the ID of the team name in Teams Table.

I'm not 100% sure this is the correct approach.

What other solutions would be advisable?

Answer Source

You should create three tables. Something like

create table countries(id int, name varachar(100));
create table divisions(id int, country_id int, name varchar(100));
create table teams(id int, division_id int, name varchar(100));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download