When you have child table and parent table, I know that if I'll use the cascade option it will remove the appropriate child row when I'm removing some row from the parent table.
But what about when you're removing first from the child table some row this will also work? is the appropriate row from the parent table will be removed? Is it possible anyway?
Edit: I have a database for a game which include:
- playersTbl (PK = PlayerID)
- GamesTbl (PK = GameID)
- GameMovesTbl (PK = MoveID,FK = GameID)
Now when the user starts the game he must register to the game (he can be only himself or a part from a group that plays the game)
Now what I want to do is when there is just one player in some game is : When the user want to delete this player from the db, it will remove the record from the playersTbl, the appropriatet game and the game move..
Edit: Right now, the playersTbl and gamesTbl are strangers to each other. so the best solution I see is to create a new table that joins between those tables. Now my DB looks like:
- PlayersTbl (PK = PlayerID)
- JoinTbl (FK = PlayerID, GameID)
- GamesTbl (PK = GameID)
- GameMovesTbl (PK = MoveID,FK = GameID)
so if I'm using the cascade option it means that:
- PlayersTbl is parent table of JoinTbl
- JoinTbl is parent table of GamesTbl
- GamesTbl is parent table of GameMovesTbl
But whenever the user deletes some player it removes only from the PlayersTbl and the JoinTbl.. so my question is what is the best relationships between those tables so the delete option will work properly?