I have a three table structure: tournament, group and team. The tournament and group tables have a one-to-many relation, and group and team have a one-to-many relation as shown below.
How do i replicate the value of the tournament_id from group table into the group_tournament_id of team table?
i'm looking for an answer which will achieve this using the create statement like
create table team (
id serial primary key,
group_id int references group,
group_tournament_id int references group(tournament_id)
);
of course this would not work because in order to reference something it has to be unique, in this case tournament_id is not unique
i need a standard way to copy over the value of tournament_id from group into 'team' table's group_tournament_id when ever i insert group_id inside team table
edit: no longer need answer in symfony, just postgreSQL would be fine

