Home > OS >  How to make data column from parent table to be inserted into a column in the child class
How to make data column from parent table to be inserted into a column in the child class

Time:05-23

I have a parent table called: games. There I have GameID (AI), TournamentID.... Then I have another table called: badminton. There I have GameID, PlayerOneID... where everything can be null (except GameID) and games.GameID is in a relationship with badminton.GameID

Now I am creating games in the Game table with autogenerated GameID but badminton.GameID is always empty. So what I need is:

I create a row in GameID and I want from the column GameID to get that new row and to be inserted in the badminton table.

this is Game table

This is Badminton table

where I should also have new row created with just GameID of 5. I hope I explained my question because I am not really into SQL. I am sorry if its a duplicate question but I have been searching throughout the Internet for more than an hour but I couldn't find a solution that I can implement here.

CodePudding user response:

I see a few issues with your structure right now, mainly that you should probably have a unique ID for your badminton table. With your structure you could consider merging the tables. If you want to move forward with your solution, look into setting up Triggers as they will execute a query when they detect a change in any of your tables. Hope that helps

  • Related