Reputation: 27
Basically, let's say I have 5 members that I've inserted into my database and memeber #1 is selected in team Lakers, member #2 is selected in team Knicks, member 3 is in team Hornets, member #4 is in team OKC and member #5 is in team Dallas. And if I delete team Knicks I need to update member #2 automatically to not be anymore selected in team Knicks as that data doesn't exist anymore, I want member #2 team to be empty.
I'll post pictures of my app tomorrow and explain further if I need to. Hopefully someone will understand what I'm asking and what I want to do.
Upvotes: 0
Views: 96
Reputation: 122
I think you should use a linking table.
For example:
tbl_player
: player_id
, player_name
tbl_team
: team_id
, team_name
the linking table will be like this:
tbl_teamplayers
: team_id
, player_id
and you should set the table columns with DELETE
and UPDATE
CASCADE
rules
so if you delete a team or a player, the link data will automatically be deleted.
Upvotes: 1