Hi,
I'm currently trying to create a program that will update a Microsoft SQL express database.
In the database I have multiple table that are all link with primary key and foreign keys.
Let say I have...
Table A:
ID_TableA (Auto increment)
Name (char 25)
Table b:
ID_TableB (Auto increment)
description (char 45)
FK_IDTAbleA (Foreign key from table a)
Now let say I want to create a Name with a description.
So I will need to first populate table A with the name, then I will need to get the ID of that name from the tableA and use it to create the description in table B.
I don't know what are the steps to create entry in a relational database.
Do I have to first create entry in table A with the name.
Then because the ID in tableA is autoIncrement I won't be able to know what is the ID of the new name I just created, so does that mean I have to query the database to obtain the ID of the new name I have just added?
And then using that ID I can create my entry in table B since that ID will be use to populate the foreigh key of table B.
Is there a better way of doing this without having to query tableA to obtain the foreign key that need to go in tableB?
I'm currently trying to create a program that will update a Microsoft SQL express database.
In the database I have multiple table that are all link with primary key and foreign keys.
Let say I have...
Table A:
ID_TableA (Auto increment)
Name (char 25)
Table b:
ID_TableB (Auto increment)
description (char 45)
FK_IDTAbleA (Foreign key from table a)
Now let say I want to create a Name with a description.
So I will need to first populate table A with the name, then I will need to get the ID of that name from the tableA and use it to create the description in table B.
I don't know what are the steps to create entry in a relational database.
Do I have to first create entry in table A with the name.
Then because the ID in tableA is autoIncrement I won't be able to know what is the ID of the new name I just created, so does that mean I have to query the database to obtain the ID of the new name I have just added?
And then using that ID I can create my entry in table B since that ID will be use to populate the foreigh key of table B.
Is there a better way of doing this without having to query tableA to obtain the foreign key that need to go in tableB?